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

Field boost and document boost for search #1918

Closed
waylan opened this issue Dec 6, 2019 · 3 comments
Closed

Field boost and document boost for search #1918

waylan opened this issue Dec 6, 2019 · 3 comments

Comments

@waylan
Copy link
Member

waylan commented Dec 6, 2019

Previously MkDocs used field boost to boost the title field (by 10) for search results. However, when lunr.js removed support for field boost in 2.0 it was removed from MkDocs when we refactored search into a plugin. As documented in olivernn/lunr.js#312 the feature was restored to lunr.js in version 2.3.0. Therefore, we should restore the boost to the title field. We should also update lunr.js to the most recent version.

That's an easy fix. However, at the same time that lunr.js restored field boost, they also added support for boosting a document. In other words, if boost is applied to a document, that document would get returned higher in the list of search results. It occurs to me that we could implement this with a meta-data value by adding support for a boost (or search priority or other, better name) as a meta-data key. The key would then be added to each entry in the JSON data used to build the search index. When building the index, the value of that key could be applied as document boost. That would allow site authors to better control search results to ensure that certain pages always appear higher up in the results.

However, I'm not sure if there is any demand for such a feature. Field boost will definately be restored. but we may only add document boost if we get demand for it here. Please reply below.

@waylan
Copy link
Member Author

waylan commented Dec 6, 2019

👍 this comment to vote for document boost or 👎 this comment to vote against document boost.

@rusefillc
Copy link

Yes, there is demand for for title to be boosted in search, as is search is weird.

@pawamoy
Copy link
Sponsor Contributor

pawamoy commented Apr 17, 2024

Nowadays (2024) lunr.js is unmaintained (last commit 2020). While we welcome enhancements to existing themes, we're also discussing creating a new, better default theme, which would probably use something else than lunr.js.

Field boost is by the way already supported in Material for MkDocs' own search plugin. @squidfunk also stated that he and his team are working on a standalone search plugin that is theme-agnostic and will bring such functionality, see the discussion starting here #3560 (comment).

For these reasons, we'll close this as not planned! If someone wants to work on this anyway, we can re-open the issue.

@pawamoy pawamoy closed this as not planned Won't fix, can't repro, duplicate, stale Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@waylan @pawamoy @rusefillc and others