Skip to content

Commit

Permalink
Add support for DEBUG_SEARCH_WEIGHTS
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Jul 2, 2022
1 parent 7993ce7 commit 9cf85e8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .config/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,12 @@
"external": false,
"@internal": false
},
"searchGroupBoosts": {
"Classes": 2.0,
"Interfaces": 2.0,
"Enumerations": 2.0,
"Type Aliases": 2.0
},
"searchInComments": true,
"logLevel": "Verbose"
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

### Features

- The `DEBUG_SEARCH_WEIGHTS` global variable can now be set on `window` to add search scoring information in the search results.

## v0.23.4 (2022-07-02)

### Bug Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function updateResults(
// boost by exact match on name
if (row.name.toLowerCase().startsWith(searchText.toLowerCase())) {
boost *=
1 + 1 / (Math.abs(row.name.length - searchText.length) * 10);
1 + 1 / (1 + Math.abs(row.name.length - searchText.length));
}

item.score *= boost;
Expand All @@ -182,6 +182,9 @@ function updateResults(

// Bold the matched part of the query in the search results
let name = boldMatches(row.name, searchText);
if (globalThis.DEBUG_SEARCH_WEIGHTS) {
name += ` (score: ${res[i].score.toFixed(2)})`;
}
if (row.parent) {
name = `<span class="parent">${boldMatches(
row.parent,
Expand Down

0 comments on commit 9cf85e8

Please sign in to comment.