zettel icon indicating copy to clipboard operation
zettel copied to clipboard

Implented Search for Notes

Open athul opened this issue 5 years ago • 6 comments

I have been working on the Search implementation. I had to generate an Index File with the title and tags as JSON and use that with some Client Side JS to make it working. I have deployed the docs of zettel wrt this PR. You can find it here :point_right: https://zettel-search.surge.sh/

Do provide feedback on where it could be changed or not

athul avatar Nov 08 '20 13:11 athul

The prototype looks nice.

image

Any idea why the null is appearing?

BTW, did you checkout LunrJS which generates an index file automatically?

mr-karan avatar Nov 09 '20 05:11 mr-karan

Lunr.js still says to build an Index for static sites

For large numbers of documents, it can take time for Lunr to build an index. The time taken to build the index can lead a browser to block; making your site seem unresponsive. A better way is to pre-build the index, and serve a serialised index that Lunr can load on the client side much quicker. This technique is useful with large indexes, or with documents that are largely static, such as with a static website.

Rather than using Lunr to build the index, it's easier to create an Index at Build time and is the easier option, so I went for it

Any idea why the null is appearing?

This is because no tags are given with the post. I will add a conditional clause to check if any tags are present or not

athul avatar Nov 09 '20 05:11 athul

Hey @mr-karan updated the code. The update code's demo can be found in https://zettel-search.surge.sh/ (the same url)

athul avatar Nov 16 '20 15:11 athul

@athul Thanks. Went through the changes and the code. I don't think this is a FTS and there are some errors in the search result:

image

Moreover, we can't search based on any word, it seems to only work for the headings. Is that how it's intended?

mr-karan avatar Nov 17 '20 03:11 mr-karan

The Body is not indexed(higher than 20kb search.json file) , thus yes, It isn't a FTS. Fuze.js is a fuzzy search package, if it finds anything similar to the keyword, it will respond with a result.

it seems to only work for the headings

The Indexed things are titles and tags and these are used as the search keys

athul avatar Nov 17 '20 06:11 athul

May be we can give an option to the user to include the content as well?

iamd3vil avatar Nov 17 '20 06:11 iamd3vil