jbms / sphinx-immaterial

Adaptation of the popular mkdocs-material material design theme to the sphinx documentation system
https://jbms.github.io/sphinx-immaterial/
Other
177 stars 28 forks source link

Search missing results #262

Closed mhostetter closed 6 months ago

mhostetter commented 1 year ago

I recently noticed in my docs that a search for a version specifier (eg "v0.3.5") yields no results, despite there being a page section with that exact title. I then noticed that typing "v0" yields many valid results, but typing `v0." yields nothing. I think there may a bug in the search string processing. Perhaps with handling periods?

Type "v0"

image

Type "v0."

image

2bndy5 commented 1 year ago

This may be of some interest: https://github.com/jbms/sphinx-immaterial/blob/60e246657221b941eb4e9ce3eb1910eaa1281df9/src/assets/javascripts/sphinx_search.ts#L254-L256

I'm not very helpful when it comes to the search feature though.

tunchunairarko commented 6 months ago

Hi,

While the search functionality is great, users are unable to search using strings that might contain -, _, . etc. in their search query. This is causing some issues with our users, since we have used sphinx-immaterial for documenting a codebase, and many variables, classnames, command names contain formats like part_part or part-part. Without being able to search using key entities such as variables, cli commands, classnames the search feature is loosing its usefulness.

jbms commented 6 months ago

I just created PR #307 which should fix this.

Note that compound "words" will just be split into separate terms:

"abc-def" gets split into ["abc", "def"] (and then these are searched independently) "v0.1.2" gets split into ["v0", "1", "2"]

Particularly for version numbers, this means that we will find all of the true results, but may find a lot of false results as well since any presence of "v0", "1", "2" in the document, in any order, would match. It is only in the later snippet extraction and highlighting that the full term "v0.1.2" will be used, but that happens too late to affect the relative order of documents in the results.

Still, I expect it will work well enough most of the time.