4 ms·
We use both Algolia and postgres FTS. While tsvector and GIN indices are fast, there’s a couple of downsides if you are looking for prefix based search on every
by nojvek 4y ago
We use both Algolia and postgres FTS. While tsvector and GIN indices are fast, there’s a couple of downsides if you are looking for prefix based search on every key stroke.
1) It’s based on tokenizing input, and ‘english’ config will tokenize it in unexpected ways. We had people’s name being tokenized like “eddie” to “eddi” and searching for “eddie:*” doesn’t work. Even the ‘simple’ config will tokenize it undesirably. I couldn’t find the exact config to turn it off.
2) you can index multiple columns by concat strings, but when results come back, no easy way of knowing which fields matched where to highlight the search.
3) Typo tolerance isn’t there. You have to send possible typos with OR in query. Typesense achieves this with ART index where it’s very cheap to explore more paths of a trie.
4) it’s fast, but not get results on every keystroke fast. Prefix based searching is still fairly expensive compared to token based search.
Postgres FTS is good usecase if you want to search for whole words in large document.
Typesense is nice, but I wish they built an auto-sync with postgres so one doesn’t have to deal with ETL headache.