[IMP] web: better fuzzy search

The goal of this commit is to have better search results when fuzzy
searching.  Before this commit, the position of a match was irrelevant
to the search results.  After, a match in a first position has more
weight than a match in last position.  This is better, because we often
want to find results using the first letters.

This is controversial, but I could not find a better way to do this
without rewriting the whole library myself (which might not be a bad
idea, it is only 50 lines long)
This commit is contained in:
Géry Debongnie
2016-05-04 14:46:46 +02:00
parent 51064be4b3
commit 782a4466fe
+1 -1
View File
@@ -61,7 +61,7 @@ fuzzy.match = function(pattern, string, opts) {
patternIdx += 1;
// consecutive characters should increase the score more than linearly
currScore += 1 + currScore;
currScore += 1 + currScore - idx/1000;
} else {
currScore = 0;
}