Tags with multiple words not showing up in search
todd-tech-writer opened this issue · comments
Contribution guidelines
- I've read the contribution guidelines and wholeheartedly agree
I've found a bug and checked that ...
- ... the problem doesn't occur with the
mkdocs
orreadthedocs
themes - ... the problem persists when all overrides are removed, i.e.
custom_dir
,extra_javascript
andextra_css
- ... the documentation does not mention anything about my problem
- ... there are no open or closed issues that are related to my problem
Description
When I add a tag with multiple words in it on one of my markdown pages, the page does not show up when searching for the tag.
Expected behaviour
I'd expect when searching for a multiple-word tag on my website, for the page with the tag to appear at the top of the search results.
Actual behaviour
I added the tags Correct Tag
and Find Me
to test-file.md
. When I search for the tag Find Me
in the search bar of my website, the test-file.md
page is not shown in the search results. When I only type Find
in the search bar, it will populate. See the screenshots below for an example:
Steps to reproduce
- Create a simple
mkdocs.yml
with tags and metadata - Create a tag on
test-file.md
calledFind Me
- Run mkdocs serve
- Search for
Find Me
Package versions
- Python:
3.8
- MkDocs:
1.3.0
- Material:
8.2.8
Configuration
site_name: 'Test Site'
site_description: 'Description'
site_author: 'Company'
nav:
- Home:
- Introduction: index.md
- Getting Started: test-file.md
theme:
name: 'material'
markdown_extensions:
- meta
plugins:
- search
- tags
System information
- Operating system: macOS Monterey 12.4
- Browser: Chrome
Fixed in cfe83cc. Now, this was actually surprising to me, but this StackOverflow answer explained it pretty well:
When a document field is an array, lunr assumes that the elements of the array are already split into tokens for indexing.
Thus, we need to pass the tags
entry explicitly through the tokenizer. Good catch!
Awesome, thank you!
The fix was just released as part of 8.3.4.