Skip to content

Commit

Permalink
fix: omit zero-weighted search paths
Browse files Browse the repository at this point in the history
  • Loading branch information
juice49 committed Nov 23, 2024
1 parent aff0ed3 commit f933bf8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/sanity/src/core/search/groq2024/createSearchQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]) => {
Expand Down

0 comments on commit f933bf8

Please sign in to comment.