Facets main purpose is to do the faceting aspect of the search. Text search is outsourced to other libraries, for example, you can use:
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.
The demo works, as you can see, but beyond that, there was no exhaustive testing. There are still rough edges. API can change.
Appearantly pagefind also supports faceted search and loading data from json. I found out it only after implemented this library. I want to try it out