diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-05-02 13:46:03 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-05-31 12:11:47 -0300 |
commit | 9fa29f389395de966b92a035a211a7ab403b48b8 (patch) | |
tree | eebe6df630fae7c8502be79e39d0f1d7fd331693 /src | |
parent | 1df0ffc354736c3ab776ad3d394b81e942c0f984 (diff) |
search: factor out common schema initializing behavior
Diffstat (limited to 'src')
-rw-r--r-- | src/util/searchSchema.js | 22 |
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'], }), }; |