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

switch gitbook search engine to fuse.js #1031

Closed
3 tasks done
jtbayly opened this issue Nov 24, 2020 · 13 comments
Closed
3 tasks done

switch gitbook search engine to fuse.js #1031

jtbayly opened this issue Nov 24, 2020 · 13 comments
Labels
feature a feature request or enhancement next to consider for next release
Milestone

Comments

@jtbayly
Copy link
Contributor

jtbayly commented Nov 24, 2020

Two other issues have mentioned the possibility of switching the gitbook theme to use fuse.js. This would solve language problems (Chinese not currently supported in Lunr) and speed problems (long books are unusable without pre-building the search index in Lunr).

Currently bs4_book uses fuse, and I'm interested to hear whether others would like to see the search engine replaced in the gitbook theme, especially from the maintainers.


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('bookdown'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/bookdown').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@yihui
Copy link
Member

yihui commented Nov 24, 2020

Yes, we'll replace lunr.js with fuse.js. Thanks for the suggestion!

@apreshill
Copy link
Contributor

I would just like to more enthusiastically upvote this issue 🤣

@Scinawa
Copy link

Scinawa commented Feb 22, 2021

Thank you! :)

@cderv
Copy link
Collaborator

cderv commented Mar 24, 2021

Listing some search improvement :

@cderv
Copy link
Collaborator

cderv commented Apr 2, 2021

For reference another alternative: https://stork-search.net/

We need to evaluate with other projects as it could be a better candidate.

@jtbayly
Copy link
Contributor Author

jtbayly commented Apr 2, 2021

Stork Search looks fairly heavy. I left a comment about the index size here, but that is already ignoring the sizes of stork.wasm and stork.js, which together add up to about 600KB on their own.

It's fast, but I'm not sure it scales until they get the index size under control. Even then I'm leery of the extra 600KB added to the page size.

For the sake of comparison, the search engine that SphinxDoc uses doesn't search on every keystroke, just when you hit return. However, it creates an index that is less than 40KB for my book that is 1.1MB. Then when you do a search it loads the data only from the files where the result is found. In other words, the worst case scenario in terms of size is the size of the content being searched, plus the size of the index (tiny) and all the rest of the javascript on the page is 51KB, the majority of that being jquery. I threw the large book that is unusable on bookdown into sphinx-doc for a quick test. You can check it out and see the search working here.

@jtbayly
Copy link
Contributor Author

jtbayly commented Apr 2, 2021

Note that this post was linked in a previous discussion, and it discusses some of the options and tradeoffs on speed.

Here's another comparison of several engines:
https://github.com/fiatjaf/search-comparison

And here's another showing popularity, if that matters:
https://www.npmtrends.com/elasticlunr-vs-fuse.js-vs-fuzzy-vs-fuzzysearch-vs-lunr-vs-reds-vs-search-index

@yihui yihui added this to the v0.23 milestone Apr 15, 2021
@cderv
Copy link
Collaborator

cderv commented Apr 19, 2021

Just sharing this issue #1141 so that we don't forget that search should work in all kind of text, included indent text

@jtbayly
Copy link
Contributor Author

jtbayly commented Apr 19, 2021

Perhaps I should open another issue, but is it possible to also get Elasticsearch supported by bookdown? Am I right in understanding that it’s already supported in related projects like pkgdown?

@cderv
Copy link
Collaborator

cderv commented Apr 19, 2021

I think pkgdown will use fuse.js too to have a local search. Currently, pkgdown allows to connect an online service provided by Algolia called DocSearch: https://pkgdown.r-lib.org/articles/search.html
but this require an API key, some other requirement and online service I believe.
This is indeed another topic than this change to fuse.js here.

@jtbayly
Copy link
Contributor Author

jtbayly commented Apr 20, 2021

Sorry to distract, then.

@yihui yihui closed this as completed in 0b93352 Jun 22, 2021
@yihui
Copy link
Member

yihui commented Jun 22, 2021

You can use fuse now: https://github.com/rstudio/bookdown/blob/master/NEWS.md#changes-in-bookdown-version-023

remotes::install_github('rstudio/bookdown')

@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature a feature request or enhancement next to consider for next release
Projects
None yet
Development

No branches or pull requests

5 participants