« 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/util
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/util
parentfcc45e386df65c68969391c7b113b6232c76c82a (diff)
search, upd8: share schema between client and upd8 code
Diffstat (limited to 'src/util')
-rw-r--r--src/util/searchSchema.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/util/searchSchema.js b/src/util/searchSchema.js
new file mode 100644
index 00000000..99ba869a
--- /dev/null
+++ b/src/util/searchSchema.js
@@ -0,0 +1,22 @@
+// Index structures shared by client and server.
+
+export function makeSearchIndexes(FlexSearch) {
+  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"],
+    }),
+  };
+
+  return indexes;
+}