diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-05-18 21:31:48 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-05-31 12:11:57 -0300 |
commit | 4e8fb6941a62ae6ece162ade04213815f67d60c7 (patch) | |
tree | d655ddd226aabef3b1f0ae3d122405b8f1eb5a63 /src/static/js/search-worker.js | |
parent | 2fabadd375a05c79b37719abd5b41abcfa4ac0de (diff) |
client: experimental [artTags, artTags] match
Diffstat (limited to 'src/static/js/search-worker.js')
-rw-r--r-- | src/static/js/search-worker.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/static/js/search-worker.js b/src/static/js/search-worker.js index ab7830c0..6d4ed52a 100644 --- a/src/static/js/search-worker.js +++ b/src/static/js/search-worker.js @@ -389,6 +389,7 @@ function queryGenericIndex(index, query, options) { ['kind', 'primaryName', 'groups', 'artTags'], ['kind', 'primaryName', 'groups'], ['kind', 'primaryName', 'contributors'], + ['kind', 'primaryName', 'artTags'], ['kind', 'parentName', 'groups', 'artTags'], ['kind', 'parentName', 'artTags'], ['kind', 'groups', 'contributors'], @@ -402,11 +403,18 @@ function queryGenericIndex(index, query, options) { ['primaryName', 'groups', 'artTags'], ['primaryName', 'groups'], ['primaryName', 'contributors'], + ['primaryName', 'artTags'], ['parentName', 'groups', 'artTags'], ['parentName', 'artTags'], ['groups', 'contributors'], ['groups', 'artTags'], + // This prevents just matching *everything* tagged "john" if you + // only search "john", but it actually supports matching more than + // *two* tags at once: "john rose lowas" works! This is thanks to + // flexsearch matching multiple field values in a single query. + ['artTags', 'artTags'], + ['contributors', 'groups'], ['primaryName', 'contributors'], ['primaryName'], @@ -426,7 +434,11 @@ function queryGenericIndex(index, query, options) { (groupedParticles.get(keys.length) ?? []) .flatMap(permutations) .map(values => values.map(({terms}) => terms.join(' '))) - .map(values => Object.fromEntries(stitchArrays([keys, values]))); + .map(values => + stitchArrays({ + field: keys, + query: values, + })); const boilerplate = queryBoilerplate(index); @@ -455,7 +467,7 @@ function queryGenericIndex(index, query, options) { for (const interestingFieldCombination of interestingFieldCombinations) { for (const query of queriesBy(interestingFieldCombination)) { const idToMatchingFieldsMap = new Map(); - for (const [field, fieldQuery] of Object.entries(query)) { + for (const {field, query: fieldQuery} of query) { for (const id of particleResults[field][fieldQuery]) { if (idToMatchingFieldsMap.has(id)) { idToMatchingFieldsMap.get(id).push(field); |