-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Search with Elasticlunr #472
Conversation
@Phaiax, would you be able to add a link to your proof-of-concept version in the description so people can see what the user-facing search will be like? |
@Phaiax I've updated elasticlunr-rs, and the generated indexes actually work now. However, for search to not miss any results we need the stemmer used to generate the index to be identical to the one used to search. The version of elasticlunr-rs on crates.io uses a stemmer from rust-stemmers, which doesn't quite have the same output. The version on master on the repo uses a port of the stemmer from elasticlunr.js, but there's a bug where it doesn't work on words ending in "ted" or "ting". Until I get that fixed there may be results missing if you use generated indexes. |
@mattico: Nice (I saw your comment in the reddit What's everyone working on thread :) ) Today I added configurability. Tomorrow I will update the proof of concept and do the key up/down handler. One problem appeared. My teaser algorithm is way too slow and needs a rework. In the above example, it did not matter, but it is causing lags in the official rust book. |
@Phaiax, I just had a look at the configuration stuff and it seems pretty good so far. Something that occurred to me is whether we want to have search enabled by default or not (e.g. |
/// The searchoptions for elasticlunr.js | ||
#[derive(Serialize)] | ||
struct SearchOptions { | ||
bool: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, what does this guy do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mimics the structure of the searchconfig
object, that elasticlunr expects. At first i serialized the config::Search
struct, but that uses kebab-case which is not nice and would cause hidden breakage if modified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah fair enough, so it's a elasticlunr-specific thing then. I thought bool
was an unusual choice for a variable in a Rust program, given it's also the name of a primitive type.
I updated the previews. Links in first post. |
I will measure the slowdown. |
Oh, and I renamed the package (but not the crate!) to "elasticlunr-rs". |
Almost done. (Commit when elasticlunr-rs 0.2.1 is pushed to crates.io) Timing with the rust book, second edition:
You decide if it should be enabled by default, but I think it should. For small books it does not make a difference and for large books such as rust book, they will probably tell their contributors about this option. |
…gs for fonts and png.
…use nightly requirement)
…light search terms.
* remove searchindex feature (nightly requirement of elasticlunr-rs dropped) * some documentation * refactor BookItems iterator * add iterator for parents * Include paragraph structure in hierarchy * Fix url and specialchar handling * Use complete index
…if search is disabled
@Michael-F-Bryan this is ready to merge. |
Added two more things, but now it should be ready. |
@Phaiax, what are your thoughts on adding a couple tests to this? We'll want to ensure search index generation doesn't accidentally get broken if those sections get refactored later on. Would it make sense to add a couple integration tests for search under the |
Sorry @Phaiax, it looks like merging #491 broke a fair amount of this PR due to conflicts 😞 We can probably remove most of the changes this PR makes to the book's internal representation because they will have (mostly) been dealt with in #491. So this PR "only" needs to worry about the html renderer and adding a |
@Michael-F-Bryan I'm still planning to do this, but I have limited time in the moment |
No stress 🙂 I'd found myself with a lot of spare time recently and was just going through any outstanding PRs and issues, seeing if there's anything I can do to help them along. I really like this PR and your proof-of-concept looks awesome, so if there's anything I can do to help don't hesitate to let me know! |
I'm working on updating this PR: https://github.com/mattico/mdBook/tree/search-eljs-rebase It's mostly complete, but there are a few JS & styling bugs, and the index is missing some things. @Phaiax, if you modified the stylus files, could you push your changes? It would help me out a lot. |
@mattico, I've got a couple of css/js changes to bring it inline with the original. I've pushed this to this branch here: https://github.com/cetra3/mdBook/tree/search-eljs-css |
@cetra3 Moving the searchbar into the header was deliberate, I thought it worked better with the sticky header that we have now. Of course, then the results shouldn't be stuck into the top of the document... Yeah I'll change it back to how it was, we can have style discussions after this is merged. Thanks for the fixes! |
@mattico yeah it can be changed. I was just having a hard time lining up the search input with the search text, as there is some indentation with the icons. |
I'd say yes. |
Belongs to Issue #51 , Proof of concept of mdbooks book and of the rustbook
This PR is not ready for merging, but I wanted to allow reviews.
Tracking: