« get me outta code hell

search, upd8: share schema between client and upd8 code - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/search.js
diff options
context:
space:
mode:
authorGio <sethg@ipi.org>2024-03-26 20:08:52 -0500
committer(quasar) nebula <qznebula@protonmail.com>2024-05-31 12:11:45 -0300
commitc364e42237493bf8985da23fdc394df735fe6c3f (patch)
treeeed0a569dcdb7731a8f804ded8fc41ee75c3d5e3 /src/search.js
parentfcc45e386df65c68969391c7b113b6232c76c82a (diff)
search, upd8: share schema between client and upd8 code
Diffstat (limited to 'src/search.js')
-rw-r--r--src/search.js20
1 files changed, 3 insertions, 17 deletions
diff --git a/src/search.js b/src/search.js
index cb4db7bb..9b5d2d7a 100644
--- a/src/search.js
+++ b/src/search.js
@@ -8,6 +8,8 @@ import FlexSearch from 'flexsearch';
 import {logError, logInfo, logWarn} from '#cli';
 import Thing from '#thing';
 
+import {makeSearchIndexes} from './util/searchSchema.js';
+
 export async function writeSearchIndex({
   wikiCachePath,
   wikiData,
@@ -21,23 +23,7 @@ export async function writeSearchIndex({
   // 2. Add documents to index
   // 3. Save index to exportable json
 
-  // Copy this block directly into clientSearch.js
-  const indexes = {
-    albums: new FlexSearch.Document({
-      id: "reference",
-      index: ["name", "groups"],
-    }),
-
-    tracks: new FlexSearch.Document({
-      id: "reference",
-      index: ["name", "album", "artists", "directory", "additionalNames"],
-    }),
-
-    artists: new FlexSearch.Document({
-      id: "reference",
-      index: ["names"],
-    }),
-  };
+  const indexes = makeSearchIndexes(FlexSearch);
 
   for (const album of wikiData.albumData) {
     indexes.albums.add({