Skip to content

Commit d60cb50

Browse files
committed
Implement search scorer to deprioritise retro notes
1 parent 4eb6e31 commit d60cb50

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

doc/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# For the full list of built-in configuration values, see the documentation:
44
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
import os.path
56

67
# -- Project information -----------------------------------------------------
78
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
@@ -78,6 +79,8 @@
7879
html_last_updated_fmt = ""
7980
html_show_copyright = False
8081

82+
html_search_scorer = os.path.join(os.path.dirname(__file__), "searchscorer.js")
83+
8184
spelling_lang = "en_GB"
8285
spelling_filters = ["enchant.tokenize.MentionFilter"]
8386
spelling_warning = True

doc/searchscorer.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
var Scorer = {
2+
score: result => {
3+
var [docName, title, anchor, descr, score, filename] = result
4+
console.log(docName, title, anchor, descr, score, filename);
5+
6+
// Deprioritize instrument details (but still include them in results)
7+
if (docName.includes("instrument_details")) {
8+
score -= 100000;
9+
}
10+
11+
// Deprioritize retrospective-notes heavily (but still include them in results)
12+
if (docName.includes("retrospective-notes")) {
13+
score -= 1000000;
14+
}
15+
16+
return score
17+
},
18+
19+
// query matches the full name of an object
20+
objNameMatch: 11,
21+
// or matches in the last dotted part of the object name
22+
objPartialMatch: 6,
23+
// Additive scores depending on the priority of the object
24+
objPrio: {
25+
0: 15,
26+
1: 5,
27+
2: -5,
28+
},
29+
// Used when the priority is not in the mapping.
30+
objPrioDefault: 0,
31+
32+
// query found in title
33+
title: 15,
34+
partialTitle: 7,
35+
36+
// query found in terms
37+
term: 5,
38+
partialTerm: 2,
39+
};

0 commit comments

Comments
 (0)