From f933bf839bbf94f428058e164091da2b16f880f0 Mon Sep 17 00:00:00 2001 From: Ash Date: Sat, 23 Nov 2024 16:56:47 +0000 Subject: [PATCH] fix: omit zero-weighted search paths --- .../src/core/search/groq2024/createSearchQuery.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/sanity/src/core/search/groq2024/createSearchQuery.ts b/packages/sanity/src/core/search/groq2024/createSearchQuery.ts index c08b1cfd3adb..8f2fc5edc3ec 100644 --- a/packages/sanity/src/core/search/groq2024/createSearchQuery.ts +++ b/packages/sanity/src/core/search/groq2024/createSearchQuery.ts @@ -69,10 +69,12 @@ export function createSearchQuery( .map(({typeName, paths}) => paths.map((path) => ({...path, typeName}))) .flat() - const groupedSpecs = groupBy( - flattenedSpecs, - (entry) => `text::matchQuery(${entry.path}, $__query), ${entry.weight}`, - ) + const groupedSpecs = groupBy(flattenedSpecs, (entry) => { + if (entry.weight === 0) { + return undefined + } + return `text::matchQuery(${entry.path}, $__query), ${entry.weight}` + }) const score = Object.entries(groupedSpecs) .map(([args, entries]) => {