-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boost title-matching scores if main title #12393
Conversation
Related to sphinx-doc#12391. Intended as a proof of concept, not a full solution.
@@ -328,10 +328,14 @@ const Search = { | |||
for (const [title, foundTitles] of Object.entries(allTitles)) { | |||
if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) { | |||
for (const [file, id] of foundTitles) { | |||
let score = Math.round(100 * queryLower.length / title.length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100 appears to be a total magic number AFAICT
// score these a little bit above document matches, with more of a boost | ||
// for main document titles | ||
let baseScore = Scorer.title + (isMainTitle ? 2 : 1) | ||
let score = Math.round(baseScore * queryLower.length / title.length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let score = Math.round(baseScore * queryLower.length / title.length) | |
let baseScore = (isMainTitle ? Scorer.title : Scorer.partialTitle) + 1 |
Got more relevant results by doing the above, but it feels even more hacky. Also comes at the cost of pushing subtitle matches even further down.
I've rolled this into the test coverage added by #12441, and it allows those tests to pass (with one small unrelated test failure that occurred due to a score-change on an existing test), and then applied some adjustments/refactoring - let me know what you think! |
#12441 looks good! Let's close this in favour of that, this was only intended as a prototype. |
Feature or Bugfix
Purpose
Trying to make sure that title matches don't get unnecessary prominence. Intended as a proof of concept, not a full solution.
Detail
TBD
Relates