modified scoring

This commit is contained in:
2026-01-14 20:56:38 +01:00
parent 4b3779baa7
commit 1b09d3707a
+7 -4
View File
@@ -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;
} }