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

Tweaking fuse.js configuration to improve search results #1319

Merged
merged 6 commits into from May 25, 2023

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented Mar 17, 2022

Context: https://community.rstudio.com/t/bookdown-search/131042/12

  • Add ignoreFieldNorm: true to fuse js

@jtbayly
Copy link
Contributor

jtbayly commented May 5, 2022

Hey @cderv ,

I finally got around to testing this in the javascript console. I didn't specifically test this version of the code, since it was easy to just set ignoreFieldNorm: true in the browser.

It solved the problem we were discussing here: https://community.rstudio.com/t/bookdown-search/131042

If you were to make this change, it would mean that shorter fields wouldn't be scored higher than longer fields. Given that...

  1. we are currently not returning all of the exact matches, which seems to me to be a clear failure, meaning this change will cause some search results to be included that are high quality, and
  2. my limited testing doesn't show returning low quality results after this

I think it makes sense to make this change at least in the dev version so it can receive wider testing.

@jtbayly
Copy link
Contributor

jtbayly commented May 5, 2022

I should have mentioned, we'd want to do this in the gitbook version, too, right? I'm not using the bs4_book theme.

@cderv
Copy link
Collaborator Author

cderv commented May 5, 2022

Thanks !

we'd want to do this in the gitbook version, too, right?

gitbook() is using default configuration for fuse.js. That is to the user to define the config desired in YAML. bs4_book() is more opinionated so hence this change there.

which seems to me to be a clear failure, meaning this change will cause some search results to be included that are high quality,

Can we improve this ?

@jtbayly
Copy link
Contributor

jtbayly commented May 5, 2022

Sorry that sentence was unclear. What I meant is that in my limited testing I was only able to find it improving things: Exact matches from longer paragraphs were now showing up in search results as expected.

@cderv cderv marked this pull request as ready for review May 25, 2023 14:03
@cderv cderv linked an issue May 25, 2023 that may be closed by this pull request
@cderv cderv merged commit e3cae95 into main May 25, 2023
@cderv cderv deleted the bs4_book/tweak-fuse branch May 25, 2023 14:27
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search in bs4_book often missing results
2 participants