-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Describe the bug
Certain multi-term search queries will generate duplicate sets of search results.
This is due to how performObjectSearch is written, where the criteria for result inclusion is if the object term appears in the fullname and each of the otherTerms appears in the haystack. Since both fullname and haystack contain the name as a substring, a two-term search query that has terms that are both substrings of name will result in performObjectSearch outputting the same set of results for each term.
As there is no code to guard against duplication of results, the duplicate results show up in the final output.
How to Reproduce
Search 'builders changes' on the Sphinx docs. Duplicate results appear at the bottom of the page, see attached screenshot.
In general, inspecting the objects index to get an object name and decomposing a name into two terms will result in the same error.
Expected behavior
Each search result should appear only once.
Your project
https://github.com/sphinx-doc/sphinx
Screenshots
The outputs from each of the object and terms search method calls:

OS
Mac
Python version
3.9
Sphinx version
4.4.0
Sphinx extensions
No response
Extra tools
No response
Additional context
Relevant previously closed issue: #3911

