Skip to content

Commit

Permalink
HTML search: add test coverage for index-entry ranking
Browse files Browse the repository at this point in the history
  • Loading branch information
jayaddison committed Aug 11, 2024
1 parent 7274236 commit a2588f4
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/js/fixtures/titles/searchindex.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions tests/js/roots/titles/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,17 @@ the subject area they're researching.

.. automodule:: relevance
:members:

Result Scoring
--------------

Many search engines assign a numeric score to documents during retrieval of
results - and this score is often used to determine the order in which they
will be presented to the user.

For example, if a user issues a query for a two words, then documents that
contain both of the words would typically be scored more highly than documents
which only contain one of them.

By evaluating search results and collecting user feedback over time, we can
attempt to align document :index:`!scoring` with :index:`relevance`.
28 changes: 28 additions & 0 deletions tests/js/searchtools.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,34 @@ describe('Basic html theme search', function() {
checkRanking(expectedRanking, results);
});

it('should score a title match above a standard index entry match', function() {
eval(loadFixture("titles/searchindex.js"));

expectedRanking = [
['relevance', 'Relevance', ''], /* title */
['index', 'Main Page', '#index-1'], /* index entry */
];

searchParameters = Search._parseQuery('relevance');
results = Search._performSearch(...searchParameters);

checkRanking(expectedRanking, results);
});

it('should score a priority index entry match above a title match', function() {
eval(loadFixture("titles/searchindex.js"));

expectedRanking = [
['index', 'Main Page', '#index-0'], /* index entry */
['index', 'Main Page > Result Scoring', '#result-scoring'], /* title */
];

searchParameters = Search._parseQuery('scoring');
results = Search._performSearch(...searchParameters);

checkRanking(expectedRanking, results);
});

it('should score a main-title match above a subheading-title match', function() {
eval(loadFixture("titles/searchindex.js"));

Expand Down

0 comments on commit a2588f4

Please sign in to comment.