christian-fei / Simple-Jekyll-Search

A JavaScript library to add search functionality to any Jekyll blog.
https://christian-fei.github.io/Simple-Jekyll-Search/
MIT License
1.34k stars 203 forks source link

Add exact match with space usecase #166

Closed sylhare closed 3 years ago

sylhare commented 3 years ago

Hi @christian-fei

I have came up with this new use case that could be added to the search. While using the search I am often looking for something that exactly matches the word I input.

However when for example looking for test, if an article had tester in it, it would come up too which is okay. So I thought, if you're looking for test only you would do like auto-complete and add a space at then end to specify that the word your looking for is just test, the extra space meaning it shouldn't match tester.

The same if you are looking for hello world and you find results for hello amazing world, by adding a space at the end, you mean that you are looking for the exact match like hello world won't return hello amazing world only articles with hello world in it.

Here would be my implementation of it for the literal search. I have added some test cases so you can see how it works. Let me know what you think, I could add a note in the documentation if needed.

christian-fei commented 3 years ago

Hey @sylhare , thanks! Looks like a good idea, meeerged!