atriusmaps-node-sdk
Version:
This project provides an API to Atrius Personal Wayfinder maps within a Node environment. See the README.md for more information
29 lines (22 loc) • 713 B
JavaScript
;
var FlexSearch = require('flexsearch');
var simple = require('./flexsearchExports/simple.js');
const NON_ASCII_LANGUAGES = ['ko', 'ja', 'zh-Hans', 'zh-Hant'];
const getFlexSearchInstance = ({ lang, type = 'standard' }) => {
const options = {
tokenize: 'reverse',
rtl: lang === 'ar', // only for arabic
stemmer: {
s: '',
es: '',
ies: 'y'
},
encode: simple.encode
};
// Use the full tokenizer for non-ASCII languages and for standard searching
// but use "forward" for typeahead
if (NON_ASCII_LANGUAGES.includes(lang))
options.tokenize = 'full';
return new FlexSearch.Index(options)
};
exports.getFlexSearchInstance = getFlexSearchInstance;