Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upHave a search bar #51
Comments
This comment has been minimized.
This comment has been minimized.
|
A search bar would indeed be very useful, but I don't think it's trivial to implement. Ideally there would be some priority, like this:
that would require to parse the markdown a second time, maybe we can hook into the parser from pulldown-cmark without the renderer?
A more general approach could be to specify high priority keywords in |
azerupi
added
the
Enhancement
label
Sep 15, 2015
azerupi
added this to the
0.0.3 milestone
Sep 25, 2015
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
Is anyone else interested in working on this? If not, I might take a crack at generating a naive search index and seeing how it works on the rust book. |
This comment has been minimized.
This comment has been minimized.
|
I have exams until end of January, so.. be my guest! I think using lunr.js has been considered in the past, so maybe take a look. But if you have other ideas, go ahead. I haven't done a lot of research about the subject. If you have any question about the project, or you want to share advancement on this matter, feel free to post here! Good luck |
azerupi
modified the milestones:
0.0.5,
0.0.4
Dec 29, 2015
azerupi
added
Status: Claimed
and removed
Type: Enhancement
labels
Jan 9, 2016
azerupi
removed this from the
0.0.6 milestone
Jan 21, 2016
This comment has been minimized.
This comment has been minimized.
ghost
commented
Mar 10, 2017
•
|
So I just noticed I can't search the Rust reference anymore, which isn't really helpful. Looking already existing search frameworks has resulted in these:
Using Tantivy would require compiling to asmjs (I guess around 10MB), or rewriting the search functionality in JS. And the search index needs to be deployed with the book. With the two JS variants the situation is a bit different: The index could be generated during compilation with node.js, or when the book is opened. I personally prefer the last option. It saves space for the Index, does not introduce additional build dependencies and the search framework can be easily updated. |
This comment has been minimized.
This comment has been minimized.
I wasn't aware there was a search functionality in the old reference? Or was it just the browsers Granted, it's not intuitive and a real search functionality would be better :) |
This comment has been minimized.
This comment has been minimized.
|
@azerupi you are correct on all counts. |
azerupi
added
S-Wishlist
T-Enhancement
and removed
Status: Claimed
labels
May 16, 2017
This comment has been minimized.
This comment has been minimized.
crumblingstatue
commented
Jul 8, 2017
|
Just here because I also ran into rust-lang-nursery/reference#73. |
This comment has been minimized.
This comment has been minimized.
lilianmoraru
commented
Jul 10, 2017
|
I wanted to open this same issue... |
This comment has been minimized.
This comment has been minimized.
|
Hi @crumblingstatue and @lilianmoraru search is certainly somewhere on the wishlist but currently we have no ETA for such a feature. But if anyone is willing to start working on it (or even start a discussion about possible implementation) they are very welcome! |
This comment has been minimized.
This comment has been minimized.
|
There are two paths I can see with this implementation. Use Lunr JS in the front endThe first is simply using lunr.js and doing everything in the frontend (pretty inefficient as the site gets bigger). This is something that mkdocs does already. Process would be to generate a JSON document that lunr.js can load and use to provide search capabilities. This would just be an extra output type. Use Tantivy in the back endThe second would be to support a server-based search implementation. This would mean though that mdbook wouldn't be a purely static output, rather it would require a server to serve requests. Something like tantivy would be a perfect fit. Taking it a step further maybe compiling to WASM so you could run it on the front end, although I don't know how feasible that would be. Process here would be maybe to switch it on as a flag, but have it running in the backend as a server, and have tantivy reindex on build. I think that tantivy would provide more performant results than lunr js but would no longer be a purely static output. |
This comment has been minimized.
This comment has been minimized.
|
Thanks for the input!
Yeah I think that loosing the static aspect is a really big drawback. I am not sure I would be willing to accept that. Gitbook uses Lunr, I think that is the way to go, at least for now. |
This comment has been minimized.
This comment has been minimized.
|
Unfortunately introducing dynamic backend requirement as a requirement would be a nogo for me in terms of rust-cookbook maintenance I would also go with the Lunr.js. It seams really snappy on large gitbooks (on par or larger than rust-book) that I've tested sofar (both when searching the index and with full text search). I think that we might think about optimization once we encounter any significant performance problems. |
This comment has been minimized.
This comment has been minimized.
|
Yep, I figured that a dynamic backend wouldn't be appropriate, but put it out there as a possible option. I still like the WASM idea though! Don't know if that is feasible at this stage, but would be awesome. Is NPM/Node already a requirement for building using mdbook? I couldn't see a package.json anywhere. If so, you can use lunr.js to prebuild an index which might speed things up a little bit. |
This comment has been minimized.
This comment has been minimized.
It is not required for building mdBook, but it is required as a dev dependency to compile the stylus files.
I would definitely build the index at build time. Is Lunr required for this or is it simple enough to do it ourselves with Rust? |
This comment has been minimized.
This comment has been minimized.
|
awesome! |
This comment has been minimized.
This comment has been minimized.
Phaiax
commented
Oct 2, 2017
|
I did a first stab at the UI, please comment. For demonstration purposes, it indexes the current visible page with elasticlunr.js and searches that.
Todo:
|
This comment has been minimized.
This comment has been minimized.
|
Nice! Very cool :) Displaying the search results in the sidebar is pretty cool, but it limits the number of results we can display at any one time. I'm also not sure if it will be usable on mobile. What about something like rustdoc or having a dropdown list with the results? This would give a little more playing room to display the results in a comprehensive way.
If we do something like rustdoc (or a dropdown) we can set the limit to a high value and provide a scroll. I suppose there should be a limit to avoid really irrelevant results, but depending on the design that limit can be set to 20+ results.
I'm not sure I understand what you are proposing here. Could you elaborate? :)
Yes, that could be useful. I suppose this would rely on the search engine to provide this info along with the results? Is that a feature they provide (lunr in particular, since that is what we settled on)? Otherwise, really great job! It looks very promising |
This comment has been minimized.
This comment has been minimized.
|
@Phaiax go for it! I'm not very experienced with web stuff. Having each section be a separate document does seem to be the way to go. With the way fields are added to documents, you can't really support subsection headings unless each section is a document. For results on other pages, I was thinking using |
This comment has been minimized.
This comment has been minimized.
olivernn
commented
Oct 2, 2017
Lunr will only return you whatever you defined the 'document' reference to be, though this can be used to look up a title or summary from some other data structure.
Sounds like a url fragment, e.g. |
This comment has been minimized.
This comment has been minimized.
Sure, plus a span for highlighting |
This comment has been minimized.
This comment has been minimized.
Phaiax
commented
Oct 3, 2017
|
I moved the search results to the center, added history functionality, and fixed mobile for chrome on android at least. Probably need browser cache flush (Ctrl+Shift+R): https://phaiax.github.io/mdBook/cli/init.html I also tried to integrate More Todos:
|
This comment has been minimized.
This comment has been minimized.
lilianmoraru
commented
Oct 3, 2017
•
|
@Phaiax This looks darn nice. |
This comment has been minimized.
This comment has been minimized.
|
@Phaiax great job! That looks very slick! @lilianmoraru yes, it is just a design proposal for now using the current page as a sample. We still need to build an index during the build and hook the two up. But this is a great step forward! :) |
This comment has been minimized.
This comment has been minimized.
|
Quick status update about elasticulnr-rs. The json index looks correct except that the leaf nodes of the index don't actually link to any documents. Current plan is to port over tests from the JS version, which should uncover the issue. Then get it to work on stable, polish, docs, etc. Likely won't have time to work on this until the weekend. |
This comment has been minimized.
This comment has been minimized.
olivernn
commented
Oct 4, 2017
|
So, I've put together a basic implementation of a Lunr backend in Rust. It works, the included example will generate an index that can be loaded by lunr.js. There is a lot still to do, I've opened issues trying to cover the major ones. Also, as previously mentioned I'm still new to Rust so I'm positive there are a thousand ways the implementation could be improved, is anyone willing to lend a hand? |
This comment has been minimized.
This comment has been minimized.
Phaiax
commented
Oct 9, 2017
•
|
The search is usable now . I'm not sure about the design of the results and the preview text yet. Has anyone an idea for an algorithm to select a better snippet from the unformatted paragraph string?
It would be best to decide for some snippet that contains the area of the document where the search terms occour the most. And for testing purposes, this is the new search with the second edition of the rust book. The |
This comment has been minimized.
This comment has been minimized.
|
This looks and works awesome!
Also a slightly off topic question, would there be a way to search by some metadata added in js by hand (ie crate names in rust cookbook)? |
This comment has been minimized.
This comment has been minimized.
|
For the snippets, have a look at how solr handles this: https://lucene.apache.org/solr/guide/6_6/highlighting.html |
This comment has been minimized.
This comment has been minimized.
Phaiax
commented
Oct 22, 2017
|
This comment has been minimized.
This comment has been minimized.
Phaiax
commented
Oct 22, 2017
|
For the snippets, I chose my own algorithm, understanding the complex solr highlighters would take to much time. |
This comment has been minimized.
This comment has been minimized.
|
@Phaiax very cool!
I'd probably want the highlight as unsticky as possible (possibly removed on any kind of interaction). But someone with actual UX knowhow should probably give us some insight. For now I'd be happy to just have a js func to clear the highlight. We might consult other stakeholders. |
This comment has been minimized.
This comment has been minimized.
lilianmoraru
commented
Oct 23, 2017
|
This doesn't need to be perfect from the beginning. |
This comment has been minimized.
This comment has been minimized.
Totally agree |
This comment has been minimized.
This comment has been minimized.
|
What's the status of this? Ready for a PR or is there some more work to be done? |
This comment has been minimized.
This comment has been minimized.
Phaiax
commented
Nov 8, 2017
•
|
I am just waiting for #457 , but that would not really be a blocker. @azerupi Where are youuuuuuu? Edit: Sry for the mails, it did not show the comments after clicking on 'comment' |
This comment has been minimized.
This comment has been minimized.
|
Looks good! I have noticed a couple of things but not major, and are related to some other issues (#463 and mattico/elasticlunr-rs#2) |
This comment has been minimized.
This comment has been minimized.
|
@Phaiax & @cetra3 The repo is currently looking for new owner maintainer. We (the collaborators) will try to help some more in the meantime. I'm especially interested in this PR and hope to start nudging it forward in the upcoming days. Thanks! |
mdinger commentedSep 14, 2015
Having a search bar would be very very useful. rustbyexample has one for example. I'm not sure how it would be implemented. I'm sure this has long been wanted by the rust book.
Being able to search for programming keywords would actually make it very unusual and better than most too (outside the scope of a regular search bar though)