From bc08bf2a2dc9ae6f07eb525d74ee5290294df516 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 22 Apr 2025 11:02:43 -0300 Subject: client: search-worker: further simplify result matching logic --- src/static/js/search-worker.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/static/js/search-worker.js b/src/static/js/search-worker.js index 70eb447e..c3002b18 100644 --- a/src/static/js/search-worker.js +++ b/src/static/js/search-worker.js @@ -480,18 +480,24 @@ function queryIndex({termsKey, indexKey}, query, options) { for (const interestingFieldCombination of interestingFieldCombinations) { for (const query of queriesBy(interestingFieldCombination)) { - const commonAcrossFields = new Set(); + const [firstQueryFieldLine, ...restQueryFieldLines] = query; - for (const [index, {field, query: fieldQuery}] of query.entries()) { - const firstFieldInQuery = (index === 0); + const commonAcrossFields = + new Set( + particleResults + [firstQueryFieldLine.field] + [firstQueryFieldLine.query]); + + for (const currQueryFieldLine of restQueryFieldLines) { const tossResults = new Set(commonAcrossFields); - for (const result of particleResults[field][fieldQuery]) { - if (firstFieldInQuery) { - commonAcrossFields.add(result); - } else { - tossResults.delete(result); - } + const keepResults = + particleResults + [currQueryFieldLine.field] + [currQueryFieldLine.query]; + + for (const result of keepResults) { + tossResults.delete(result); } for (const result of tossResults) { -- cgit 1.3.0-6-gf8a5