From 49b113e79ef2baf96d746730311143f9b242bf62 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 18 May 2026 20:59:39 -0300 Subject: search: drop most interesting field combinations --- src/common-util/search-shape.js | 4 --- src/search-select.js | 63 ++++++++++++++++++----------------------- src/static/js/search-worker.js | 22 -------------- 3 files changed, 28 insertions(+), 61 deletions(-) diff --git a/src/common-util/search-shape.js b/src/common-util/search-shape.js index 3f1d9ed2..0754d3b1 100644 --- a/src/common-util/search-shape.js +++ b/src/common-util/search-shape.js @@ -21,9 +21,7 @@ const searchShape = { index: [ 'primaryName', 'parentName', - 'artTags', 'additionalNames', - 'contributors', 'groups', ].map(field => ({field, tokenize: 'forward'})), @@ -34,9 +32,7 @@ const searchShape = { index: [ 'primaryName', 'parentName', - 'artTags', 'additionalNames', - 'contributors', 'groups', ], diff --git a/src/search-select.js b/src/search-select.js index dc1508be..0f8f24e2 100644 --- a/src/search-select.js +++ b/src/search-select.js @@ -53,6 +53,31 @@ function prepareArtwork(artwork, thing, { return serializeSrc; } +function determineAlbumGroups(album, opts) { + const dividingGroups = + opts.wikiInfo.divideTrackListsByGroups; + + const artists = + album.artistContribs.map(contrib => contrib.artist); + + const artistNames = + artists.map(artist => artist.name); + + const groups = []; + + for (const group of album.groups) { + const matchesGroupName = x => compareKebabCase(group.name, x); + + if (!dividingGroups.includes(group)) + if (artistNames.some(matchesGroupName)) + continue; + + groups.push(group); + } + + return groups; +} + function determineArtistGroups(artist, opts) { const contributions = [ artist.musicContributions, @@ -228,16 +253,6 @@ function genericProcess(thing, opts) { : [thing.parentName]); - fields.artTags = - (Array.from(new Set( - (thing.isTrack - ? thing.trackArtworks.flatMap(artwork => artwork.artTags) - : thing.isAlbum - ? thing.coverArtworks.flatMap(artwork => artwork.artTags) - : [])))) - - .map(artTag => artTag.nameShort); - fields.additionalNames = (thing.constructor.hasPropertyDescriptor('additionalNames') ? thing.additionalNames.map(entry => entry.name) @@ -245,36 +260,14 @@ function genericProcess(thing, opts) { ? thing.artistAliases.map(alias => alias.name) : []); - const contribKeys = [ - 'artistContribs', - 'contributorContribs', - ]; - - const contributions = - contribKeys - .flatMap(key => thing[key] ?? []); - - fields.contributors = - contributions - .flatMap(({artist}) => [ - artist.name, - ...artist.artistAliases.map(alias => alias.name), - ]); - const groups = - (thing.isAlbum ? thing.groups - : thing.isTrack ? thing.album.groups + (thing.isAlbum ? determineAlbumGroups(thing, opts) + : thing.isTrack ? determineAlbumGroups(thing.album, opts) : thing.isArtist ? determineArtistGroups(thing, opts) : []); - const mainContributorNames = - contributions - .map(({artist}) => artist.name); - fields.groups = - groups - .filter(group => !mainContributorNames.includes(group.name)) - .map(group => group.name); + groups.map(group => group.name); return fields; } diff --git a/src/static/js/search-worker.js b/src/static/js/search-worker.js index 9ccaa95d..f3e4175a 100644 --- a/src/static/js/search-worker.js +++ b/src/static/js/search-worker.js @@ -487,29 +487,7 @@ function performSearchAction({query, options}) { const interestingFieldCombinations = [ ['primaryName'], ['additionalNames'], - - ['primaryName', 'parentName', 'groups'], - ['primaryName', 'parentName'], - ['primaryName', 'groups', 'contributors'], - ['primaryName', 'groups', 'artTags'], ['primaryName', 'groups'], - ['additionalNames', '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', 'parentName'], - ['contributors', 'groups'], - ['primaryName', 'contributors'], ]; function queryGenericIndex(query, options) { -- cgit 1.3.0-6-gf8a5