Live data from Hacker News

Libsearch: Simple index-free full-text search for JavaScript

github.com

1–10 of 21 posts

Re: Libsearch: Simple index-free full-text search for JavaScript

#4
this is 115 lines of TS, which is pretty lightweight, but some other impt table stakes might be missing that you should be aware of.

see all the JS alternatives with their sizes and feature sets and perf: https://github.com/leeoniya/uFuzzy (scroll to bottom)

i went down this path a few yrs ago and ended up picking ufuzzy: https://swyxkit.netlify.app/ufuzzy-search

Re: Libsearch: Simple index-free full-text search for JavaScript

#7
post #5

With FlexSearch or lunr or similar, building an index is so fast for “thousands of items” that it’s fine to do it when the user opens a search interface and forget it once they’re done.

For thousands of items, do you even need one?

Re: Libsearch: Simple index-free full-text search for JavaScript

#8
post #5

With FlexSearch or lunr or similar, building an index is so fast for “thousands of items” that it’s fine to do it when the user opens a search interface and forget it once they’re done.

depending on the options you need (like typo tolerance), building the index can be quite slow and use a lot of memory

Re: Libsearch: Simple index-free full-text search for JavaScript

#9
post #4

this is 115 lines of TS, which is pretty lightweight, but some other impt table stakes might be missing that you should be aware of. see all the JS alternatives with their sizes and feature sets and perf: https://github.com/leeoniya/uFuzzy (scroll to bottom) i went down this path a few yrs ago and ended up picking ufuzzy: https://swyxkit.netlify.app/ufuzzy-search

thanks, glad you like it.

you might be interested in doing a follow-up/update to your post, to use the .search() api, which does more stuff out of the box, such as outOfOrder, quoted, and negatives

Libsearch looks similar to uFuzzy (indexless regexp builder) but more simplistic. the other one i've seen that does this is sifter.js (predates uFuzzy, but i didnt discover it until researching libs to compare afterwards)

Re: Libsearch: Simple index-free full-text search for JavaScript

#10
post #7
post #5

With FlexSearch or lunr or similar, building an index is so fast for “thousands of items” that it’s fine to do it when the user opens a search interface and forget it once they’re done.

For thousands of items, do you even need one?

For typo resistance and stemming it’s useful. Mostly it depends if your search matching logic needs to do allocation per document, like if you need to concatenate 10 strings together to get the complete search text and then split that into some kind of stem array, doing that O(thousands) of times per keystroke can be laggy in JS especially on memory constrained devices because GC pressure. Better to do it once up front. Then voila, you’ve got an index.
Post reply on HN