Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tags with multiple words not showing up in search #4004

Closed
5 tasks done
todd-tech-writer opened this issue Jun 7, 2022 · 3 comments
Closed
5 tasks done

Tags with multiple words not showing up in search #4004

todd-tech-writer opened this issue Jun 7, 2022 · 3 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@todd-tech-writer
Copy link

Contribution guidelines

I've found a bug and checked that ...

  • ... the problem doesn't occur with the mkdocs or readthedocs themes
  • ... the problem persists when all overrides are removed, i.e. custom_dir, extra_javascript and extra_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:

image

image

image

Steps to reproduce

  1. Create a simple mkdocs.yml with tags and metadata
  2. Create a tag on test-file.md called Find Me
  3. Run mkdocs serve
  4. 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
@squidfunk squidfunk added the bug Issue reports a bug label Jun 7, 2022
@squidfunk
Copy link
Owner

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!

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Jun 8, 2022
@todd-tech-writer
Copy link
Author

Awesome, thank you!

@squidfunk
Copy link
Owner

The fix was just released as part of 8.3.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants