It is the monorepo repository:
- main package - facets
- InstantSearch adapter for facets
- and demo site
Facets is a client-side (though you can run it on the server) faceted search engine.
Facet - any of the definable aspects that make up a subject (as of contemplation) or an object (as of consideration)
Facets main purpose is to do the faceting aspect of the search. Text search is outsourced to other libraries, for example, you can use:
- QuickScore
- MiniSearch
- Fuse.js
- flexsearch
- and you can write an adapter for any other text search engine
The main secret ingredient is TypedFastBitSet.js - a fast set data structure. Using it and standard Map
allows us to build an inverted-index data structure. From there, it's a pretty straightforward implementation.
It is easier to show than explain. See online demo here.
The demo works, as you can see, but beyond that, there was no exhaustive testing. There are still rough edges. API can change.
The library inspired by ItemsJS. There are only three solutions that do faceted searches on the client-side:
- Tanstack table. It is not a primary purpose of the library, though it's possible
- Orama. It is quite slow in my testing
- ItemsJS
Read my article for details.
Initially, I wanted to fork ItemsJS, but I thought - it would be easier to write a library from scratch.
Warning
Appearantly pagefind also supports faceted search and loading data from json. I found out it only after implemented this library.
See:
pnpm i
pnpm run dev
Logo by Pravin Unagar from Noun Project (CC BY 3.0)
- prettier, eslint