From 9d4e4a6998e9ccc17751dac95d0c8277d7dc1d42 Mon Sep 17 00:00:00 2001 From: laowudui Date: Mon, 14 Oct 2024 16:32:27 +0800 Subject: [PATCH] fix(localSearch): update indexing logic to handle MiniSearch duplicate ID (#4251) Introduce a check to discard duplicate IDs before adding them to the index in the localSearchPlugin. This ensures that each ID is uniquely indexed, preventing any potential overwriting of existing entries. The modification enhances the reliability and accuracy of the local search functionality. --- src/node/plugins/localSearchPlugin.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/node/plugins/localSearchPlugin.ts b/src/node/plugins/localSearchPlugin.ts index d025641c..5828339d 100644 --- a/src/node/plugins/localSearchPlugin.ts +++ b/src/node/plugins/localSearchPlugin.ts @@ -134,6 +134,9 @@ export async function localSearchPlugin( if (!section || !(section.text || section.titles)) break const { anchor, text, titles } = section const id = anchor ? [fileId, anchor].join('#') : fileId + if (index.has(id)) { + index.discard(id) + } index.add({ id, text,