From da152f2b7ebd8af1a9047b1769d549d2fb413000 Mon Sep 17 00:00:00 2001 From: Alex Korytskyi Date: Sat, 7 Mar 2026 12:42:36 +0000 Subject: [PATCH 1/2] fix: try different approach with algolia by owner search --- app/composables/npm/useAlgoliaSearch.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/composables/npm/useAlgoliaSearch.ts b/app/composables/npm/useAlgoliaSearch.ts index eb10a2e7ae..b86d07a533 100644 --- a/app/composables/npm/useAlgoliaSearch.ts +++ b/app/composables/npm/useAlgoliaSearch.ts @@ -43,6 +43,7 @@ interface AlgoliaHit { modified: number homepage: string | null repository: AlgoliaRepo | null + owner: AlgoliaOwner[] | null owners: AlgoliaOwner[] | null downloadsLast30Days: number downloadsRatio: number @@ -60,6 +61,7 @@ const ATTRIBUTES_TO_RETRIEVE = [ 'modified', 'homepage', 'repository', + 'owner', 'owners', 'downloadsLast30Days', 'downloadsRatio', @@ -191,10 +193,11 @@ export function useAlgoliaSearch() { requests: [ { indexName, - query: '', + query: ownerName, offset, length, - filters: `owner.name:${ownerName}`, + typoTolerance: false, + restrictSearchableAttributes: ['owner.name', 'owners.name'], analyticsTags: ['npmx.dev'], attributesToRetrieve: ATTRIBUTES_TO_RETRIEVE, attributesToHighlight: [], @@ -217,7 +220,12 @@ export function useAlgoliaSearch() { return { isStale: false, - objects: allHits.map(hitToSearchResult), + // remove results where ownerName is not in owners and map for internal usage + objects: allHits + .filter( + hit => hit?.owner?.name === ownerName || hit?.owners?.some(o => o.name === ownerName), + ) + .map(hitToSearchResult), total: serverTotal, time: new Date().toISOString(), } From 6bbd84ce31aaeffbcd61c8ed76e9f24749758d38 Mon Sep 17 00:00:00 2001 From: Alex Korytskyi Date: Sat, 7 Mar 2026 15:19:25 +0000 Subject: [PATCH 2/2] fix: AlgoliaHit type fix --- app/composables/npm/useAlgoliaSearch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/composables/npm/useAlgoliaSearch.ts b/app/composables/npm/useAlgoliaSearch.ts index b86d07a533..9af47d07de 100644 --- a/app/composables/npm/useAlgoliaSearch.ts +++ b/app/composables/npm/useAlgoliaSearch.ts @@ -43,7 +43,7 @@ interface AlgoliaHit { modified: number homepage: string | null repository: AlgoliaRepo | null - owner: AlgoliaOwner[] | null + owner: AlgoliaOwner | null owners: AlgoliaOwner[] | null downloadsLast30Days: number downloadsRatio: number