Fixed search for languages without stemmers

This commit is contained in:
squidfunk
2018-02-01 23:47:00 +01:00
committed by Martin Donath
parent 9b717440cc
commit c002cc2881
42 changed files with 39 additions and 44 deletions

View File

@@ -170,13 +170,22 @@ export default class Result {
/* Create stack and index */
this.stack_ = []
this.index_ = lunr(function() {
const filters = {
"search.pipeline.trimmer": lunr.trimmer,
"search.pipeline.stopwords": lunr.stopWordFilter
}
/* Disable stop words filter and trimmer, if desired */
const pipeline = Object.keys(filters).reduce((result, name) => {
if (!translate(name).match(/^false$/i))
result.push(filters[name])
return result
}, [])
/* Remove stemmer, as it cripples search experience */
this.pipeline.reset()
this.pipeline.add(
lunr.trimmer,
lunr.stopWordFilter
)
if (pipeline)
this.pipeline.add(...pipeline)
/* Set up alternate search languages */
if (lang.length === 1 && lang[0] !== "en" && lunr[lang[0]]) {