Skip to content

Commit 8153449

Browse files
committed
fix(docs): score each search page once per retrieval source
1 parent 54e7402 commit 8153449

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎apps/docs/lib/search/service.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ async function hybridSearch(query: string, limit: number, signal?: AbortSignal)
135135
})
136136
continue
137137
}
138+
const seenPages = new Set<string>()
138139
list.value.forEach((row, index) => {
139140
let citation: URL
140141
try {
@@ -147,6 +148,8 @@ async function hybridSearch(query: string, limit: number, signal?: AbortSignal)
147148
if (!page || row.metadata?.contentHash !== page.contentHash) return
148149
if (citation.hash && !page.headings.some((heading) => `#${heading.id}` === citation.hash))
149150
return
151+
if (seenPages.has(page.id)) return
152+
seenPages.add(page.id)
150153
const existing = scores.get(page.id)
151154
const score = (existing?.score ?? 0) + 1 / (60 + index + 1)
152155
scores.set(page.id, {

0 commit comments

Comments
 (0)