From 4e8fb6941a62ae6ece162ade04213815f67d60c7 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 18 May 2024 21:31:48 -0300 Subject: client: experimental [artTags, artTags] match --- src/static/js/search-worker.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src') 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); -- cgit 1.3.0-6-gf8a5