[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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user