sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

[HTML search] partially-matched titles are not included in search results.

Open jayaddison opened this issue 1 year ago • 0 comments

Describe the bug

As-written, the search code for Sphinx appears intended to give a score of 7 to partial-matches of the user query against document titles. This compares to a score of 15 when one of the terms from the user query matches a title term exactly.

However: there is a bug. The code uses the variable named word that relates to one of the words from the user's original query (philos in the repro case provided below) instead of the partially-matching title term found in the index (philosphi -- the i suffix is not a typo, that's due to term stemming).

How to Reproduce

Self-construct the Sphinx project's HTML documentation from commit 574519900ee7eb8b2a1422288139bcc20b56c6d9 and host this using a local webserver (for example, by running python -m http.server -b 127.0.0.1 from the documentation build output directory).

Visit the locally-hosted project documentation using a web browser, and perform a search (keyboard shortcut: /) for the term philos.

Expected outcome: the Appendix: Deploying a Sphinx project online tutorial should be listed in the search results.

Actual outcome: the tutorial is not included in the search results.

Environment Information

Platform:              linux; (Linux-6.6.15-rt-amd64-x86_64-with-glibc2.37)
Python version:        3.11.8 (main, Feb  7 2024, 21:52:08) [GCC 13.2.0])
Python implementation: CPython
Sphinx version:        7.3.0+/574519900
Docutils version:      0.20.1
Jinja2 version:        3.1.3
Pygments version:      2.17.2

Sphinx extensions

extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo',
              'sphinx.ext.autosummary', 'sphinx.ext.extlinks',
              'sphinx.ext.intersphinx',
              'sphinx.ext.viewcode', 'sphinx.ext.inheritance_diagram',
              'sphinx.ext.coverage']

Additional context

Discovered during code review of #11958.

jayaddison avatar Mar 02 '24 18:03 jayaddison