add support for partial matches in js search

This commit is contained in:
fab 2017-07-17 23:08:42 +02:00
parent 947e01436b
commit 50172f19f6

View File

@ -391,6 +391,17 @@ var Search = {
{files: terms[word], score: Scorer.term},
{files: titleterms[word], score: Scorer.title}
];
// add support for partial matches
for (var w in terms) {
if ( w.match(word) ) {
_o.push({files: terms[w], score: Scorer.term/2})
}
}
for (var w in titleterms) {
if (w.match(word)) {
_o.push({files: titleterms[w], score: Scorer.title/2})
}
}
// no match but word was a required one
if ($u.every(_o, function(o){return o.files === undefined;})) {