diff options
author | Gio <sethg@ipi.org> | 2024-03-26 20:36:24 -0500 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-05-31 12:11:45 -0300 |
commit | 8e8011d79511d68309d99ea93688d2a64d6149a6 (patch) | |
tree | 9ae19a2b4d813097cd8d6e504f0fe21f236ba966 /src | |
parent | c364e42237493bf8985da23fdc394df735fe6c3f (diff) |
search: minor client refactor
Diffstat (limited to 'src')
-rw-r--r-- | src/static/js/client.js | 11 | ||||
-rw-r--r-- | src/util/searchSchema.js | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/static/js/client.js b/src/static/js/client.js index 650a3925..a3d63719 100644 --- a/src/static/js/client.js +++ b/src/static/js/client.js @@ -3426,23 +3426,26 @@ async function initSearch() { // Copied directly from server search.js const indexes = makeSearchIndexes(FlexSearch); - window.indexes = indexes; - const searchData = await fetch('/search-data/index.json') .then(resp => resp.json()); + // If this fails, it's because an outdated index was cached. + // TODO: If this fails, try again once with a cache busting url. for (const [indexName, indexData] of Object.entries(searchData)) { for (const [key, value] of Object.entries(indexData)) { - window.indexes[indexName].import(key, value); + indexes[indexName].import(key, value); } } + + // Expose variable to window + window.searchIndexes = indexes; } function searchAll(query, options = {}) { const results = {}; - for (const [indexName, index] of Object.entries(window.indexes)) { + for (const [indexName, index] of Object.entries(window.searchIndexes)) { results[indexName] = index.search(query, options); } diff --git a/src/util/searchSchema.js b/src/util/searchSchema.js index 99ba869a..a4604dd4 100644 --- a/src/util/searchSchema.js +++ b/src/util/searchSchema.js @@ -9,7 +9,7 @@ export function makeSearchIndexes(FlexSearch) { tracks: new FlexSearch.Document({ id: "reference", - index: ["name", "album", "artists", "directory", "additionalNames"], + index: ["name", "album", "artists", "additionalNames"], }), artists: new FlexSearch.Document({ |