Skip to content

Duplicate search results  #10227

@calebchiam

Description

@calebchiam

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

Searching 'builders changes':
image

Inspecting the objects index:
image

The outputs from each of the object and terms search method calls:
image

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions