Skip to content

Commit 2b46b78

Browse files
committed
rearrange scorer code and add comments
1 parent 915e580 commit 2b46b78

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

Doc/search_scorer.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
11
var Scorer = {
22
score: function (result) {
33
let [docname, title, anchor, descr, score, filename] = result;
4-
if (docname == "library/stdtypes" || docname == "library/functions") {
4+
5+
// boost the score of built-in functions and types
6+
const builtinPages = ["library/stdtypes", "library/functions"];
7+
if (builtinPages.includes(docname)) {
58
score += 10;
69
}
10+
711
return score;
812
},
913

14+
// all values below this line are the Sphinx defaults
15+
16+
// Additive scores depending on the priority of the object
17+
// Priority is set by object domains
18+
// (see https://www.sphinx-doc.org/en/master/extdev/domainapi.html)
1019
objPrio: {
1120
0: 15,
1221
1: 5,
1322
2: -5,
1423
},
1524
objPrioDefault: 0,
1625

17-
objNameMatch: 20,
18-
objPartialMatch: 6,
26+
objNameMatch: 11, // score if object's name exactly matches search query
27+
objPartialMatch: 6, // score if object's name contains search query
28+
29+
title: 15, // score if title exactly matches search query
30+
partialTitle: 7, // score if title contains search query
1931

20-
title: 15,
21-
partialTitle: 7,
22-
term: 5,
23-
partialTerm: 2,
32+
term: 5, // score if a term exactly matches search query
33+
partialTerm: 2, // score if a term contains search query
2434
};

0 commit comments

Comments
 (0)