top | item 42537665

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

96 points| thesephist | 1 year ago |github.com

19 comments

order

swyx|1 year ago

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

leeoniya|1 year ago

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)

no_wizard|1 year ago

I never realized search like this was this easy to build in a way.

It’s a very clever RegEx engine, essentially. Though it’s unclear to me right now how will this library handles fuzzy search (e.g. Califnia instead of California) but it’s really cool to reason about its implementation

maelito|1 year ago

I'm often using Fuse in my JS apps. So many in-app searchs cannot handle typing errors, it's frustrating.

efilife|1 year ago

Fuse is terrible performance-wise. There are many better options

https://github.com/nextapps-de/flexsearch?tab=readme-ov-file...

I tried Fuse, lunr and MiniSearch, and I stayed with MiniSearch. Great flexibility and very good performance even when I am indexing almost a million documents + many useful features.

Also, I would also recommend giving FlexSearch a try, it has some fancy algorithm that supposedly makes searches extra fast https://github.com/nextapps-de/flexsearch?tab=readme-ov-file...

jitl|1 year ago

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.

bhl|1 year ago

Any non in-memory search indices? Was hoping to find one that used indexeddb to implement fuzzy search. Maybe that’s just not as performant which is why I haven’t found a popular library yet.

andai|1 year ago

For thousands of items, do you even need one?

leeoniya|1 year ago

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

gabrieledarrigo|1 year ago

Small and simple! I love these types of programs.

Alifatisk|1 year ago

What's the benefit of index-free?

leeoniya|1 year ago

much lower memory use, and instant startup time