« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/util/searchSchema.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/util/searchSchema.js b/src/util/searchSchema.js
index 1628dbd4..d4e1a8c0 100644
--- a/src/util/searchSchema.js
+++ b/src/util/searchSchema.js
@@ -1,15 +1,18 @@
 // Index structures shared by client and server.
 
 export function makeSearchIndexes(FlexSearch) {
-  const indexes = {
-    albums: new FlexSearch.Document({
+  const doc = config =>
+    new FlexSearch.Document({
       id: 'reference',
+      ...config,
+    });
+
+  const indexes = {
+    albums: doc({
       index: ['name', 'groups'],
     }),
 
-    tracks: new FlexSearch.Document({
-      id: 'reference',
-
+    tracks: doc({
       index: [
         'name',
         'album',
@@ -25,18 +28,15 @@ export function makeSearchIndexes(FlexSearch) {
       ],
     }),
 
-    artists: new FlexSearch.Document({
-      id: 'reference',
+    artists: doc({
       index: ['names'],
     }),
 
-    groups: new FlexSearch.Document({
-      id: 'reference',
+    groups: doc({
       index: ['name', 'description', 'category'],
     }),
 
-    flashes: new FlexSearch.Document({
-      id: 'reference',
+    flashes: doc({
       index: ['name', 'tracks', 'contributors'],
     }),
   };