diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-05-03 16:59:30 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-05-31 12:11:49 -0300 |
commit | 5bcf13ab09dca78c8bafa151b1ba7e2003e21b56 (patch) | |
tree | 5d4f84675c4214943e5a4a52115b739081a80b1a /src | |
parent | 39fc3d74b1e7e193442ab77962935fb50a593c5d (diff) |
search: 'generic' index for like comparisons
Diffstat (limited to 'src')
-rw-r--r-- | src/static/js/client.js | 2 | ||||
-rw-r--r-- | src/util/search-spec.js | 55 |
2 files changed, 57 insertions, 0 deletions
diff --git a/src/static/js/client.js b/src/static/js/client.js index e570b91a..cd5aeea8 100644 --- a/src/static/js/client.js +++ b/src/static/js/client.js @@ -3667,6 +3667,8 @@ function clearSidebarSearch() { function showSidebarSearchResults(results) { const info = sidebarSearchInfo; + console.debug(`Showing search results:`, results); + const flatResults = Object.entries(results) .flatMap(([index, results]) => results diff --git a/src/util/search-spec.js b/src/util/search-spec.js index b26869a2..decfec7a 100644 --- a/src/util/search-spec.js +++ b/src/util/search-spec.js @@ -1,6 +1,61 @@ // Index structures shared by client and server, and relevant interfaces. export const searchSpec = { + generic: { + query: ({ + albumData, + artistData, + flashData, + trackData, + }) => [ + albumData, + + artistData + .filter(artist => !artist.isAlias), + + flashData, + + trackData + // Exclude rereleases - there's no reasonable way to differentiate + // them from the main release as part of this query. + .filter(track => !track.originalReleaseTrack), + ].flat(), + + process: (thing) => ({ + primaryName: + thing.name, + + additionalNames: + (Object.hasOwn(thing, 'additionalNames') + ? thing.additionalNames.map(entry => entry.name) + : Object.hasOwn(thing, 'aliasNames') + ? thing.aliasNames + : []), + + contributors: + ([ + 'artistContribs', + 'bannerArtistContribs', + 'contributorContribs', + 'coverArtistContribs', + 'wallpaperArtistContribs', + ]).filter(key => Object.hasOwn(thing, key)) + .flatMap(key => thing[key]) + .map(contrib => contrib.artist) + .flatMap(artist => [artist.name, ...artist.aliasNames]), + }), + + index: [ + 'primaryName', + 'additionalNames', + 'contributors', + ], + + store: [ + 'primaryName', + ], + }, + albums: { query: ({albumData}) => albumData, |