diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-04-22 11:02:43 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-04-22 11:02:43 -0300 |
commit | bc08bf2a2dc9ae6f07eb525d74ee5290294df516 (patch) | |
tree | 7bccabe99c6f37cbc8964901cd208e36fc54d97a /src | |
parent | 252c7f4613e6f954024f5c59193f5a7a342096dd (diff) |
client: search-worker: further simplify result matching logic
Diffstat (limited to 'src')
-rw-r--r-- | src/static/js/search-worker.js | 24 |
1 files changed, 15 insertions, 9 deletions
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) { |