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

Implented Search for Notes #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Implented Search for Notes #27

wants to merge 2 commits into from

Conversation

athul
Copy link
Contributor

@athul athul commented Nov 8, 2020

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 👉 https://zettel-search.surge.sh/

Do provide feedback on where it could be changed or not

@mr-karan
Copy link
Contributor

mr-karan commented Nov 9, 2020

The prototype looks nice.

image

Any idea why the null is appearing?

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

@athul
Copy link
Contributor Author

athul commented Nov 9, 2020

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

Added a condition to check if tags are present or not, added a condition to skip adding index page to SearchIndex
@athul
Copy link
Contributor Author

athul commented Nov 16, 2020

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

@mr-karan
Copy link
Contributor

@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?

@athul
Copy link
Contributor Author

athul commented Nov 17, 2020

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

@iamd3vil
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants