From 782a4466febda566f871ecf23000526893c2febd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 4 May 2016 14:43:13 +0200 Subject: [PATCH] [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) --- addons/web/static/lib/fuzzy-master/fuzzy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/lib/fuzzy-master/fuzzy.js b/addons/web/static/lib/fuzzy-master/fuzzy.js index d1805ff7ee8..0103eaa85bc 100644 --- a/addons/web/static/lib/fuzzy-master/fuzzy.js +++ b/addons/web/static/lib/fuzzy-master/fuzzy.js @@ -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; }