modified scoring
This commit is contained in:
@@ -171,13 +171,16 @@ data:
|
|||||||
|
|
||||||
function score(item, q) {
|
function score(item, q) {
|
||||||
const t = normalize(item.title);
|
const t = normalize(item.title);
|
||||||
const u = normalize(item.url);
|
|
||||||
if (!q) return 0;
|
if (!q) return 0;
|
||||||
|
|
||||||
// simple scoring: prefix > includes, title > url
|
if (t === q) return 200;
|
||||||
if (t.startsWith(q)) return 100;
|
if (t.startsWith(q)) return 120;
|
||||||
|
|
||||||
|
// boost if query matches start of any word
|
||||||
|
const words = t.split(' ');
|
||||||
|
if (words.some(w => w.startsWith(q))) return 95;
|
||||||
|
|
||||||
if (t.includes(q)) return 70;
|
if (t.includes(q)) return 70;
|
||||||
if (u.includes(q)) return 40;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user