Postgres as a Search Engine
anyblockers.com
anyblockers.com
Including but not limited to things that English doesn't have or only has in vestigial forms like grammatical cases, complex word morphology, declensions etc.
That'll be different depending on the language, you can't simply transliterate words to another language, the mapping may change things and the rules might be different.
For example, in English "manage / managers", are practically the same, but transliterating to Spanish can give you "gestionan / gerentes", which diverge very early on.
But yes, most (all?) European languages have vastly more complex morphology than English.
https://supabase.com/docs/guides/database/extensions/pgroong...
It looks like at best it makes Postgres aware of more characters
What techniques are you talking about that cannot be implemented in Postgres?
To be blunt, the intersection of people that know what they are doing on this front and people that choose to use Postgres for this is pretty narrow. It does happen and I've seen a few nice things built with Postgres. But mostly it's just people using the wrong tool for the job.
ParadeDB pg_search bundles Tantivy, a Lucene-inspired library inside Postgres, to give users the feature set (BM25 ranking, tokenizers, faceted search, etc.) while keeping the benefits of Postgres (keep your data normalized, avoid ETL, etc.)
Disclaimer: I work on ParadeDB
Orchestrating this outside of a few Python scripts and a single instance of postgres would have taken much more work!
It took me a while to find it, it looks like they support it via Snowball: https://github.com/snowballstem/snowball
I wish ParadeDB exposed multi-language search capability more prominently in the docs.
It was a really, really hard task 20 years ago, but I'd imagine that now there must be a drop-in grep/ag replacement for natural languages that you run once to build an index and it takes care of all this stemming, semantic embeddings and all other clever specialized things for you. Isn't there one?
And if no, what tools/libraries do exist in this area? To make something more sophisticated than in this post?
Disclaimer: I work at ParadeDB
https://austingwalters.com/fast-full-text-search-in-postgres...
Imo custom indexes are the real key to more accuracy and speed. That said, if you have <100m documents the built in search functions are great and really depends on your speed requirements.
FTS and trigram can perform quite poorly unless the data and indices are tuned properly.
2. Postgre is not serverless, so it is not easy to separate read and write, and it is not easy to auto scaling
By the time you're hitting the limitations of vertical scaling a single do-everything instance of Postgres on cloud infrastructure, you're making boatloads of money and can afford to stand up something else for search. And besides which, creating read replicas horizontally is very doable.
Though to be fair, I wouldn't implement moderately complex search on postgres, just because there are better tools for the job. Keeping data consistent between multiple systems though is "involved", and there's therefore a good argument for doing search in Postgres if your needs are simple.
Imagine a scenario where read-heavy but infrequent search queries end up pushing, say, your sessions table out of cache.
Postgres has no facilities for earmarking cache for one table vs another, so the noisy neighbor problem is real, and hard to fix. You can throw money/ram at it, but that's needlessly expensive if you have some workloads that don't require that level of performance.
The main problem I've seen is companies allowing tables to grow enormous because they never partition (by year, for instance) or archive out old stale data.
The pg_duck project has the eventual aim to implement a column storage engine for Postgres. There are a few steps to get there as it needs to be tied into the Postgres page storage and replication system. So it's not solved by the first version of pg_duck, but the team is incredible and I believe it will happen.
Neon and Oriole (acquired by Supabase) are both open source and separate storage and compute. There is a few steps more for them to go to be truly usable self hosted, but they will get there, and some of the work they are doing will hopefully be upstreamed.
I'm not saying you don't need multi-master, but I've worked on several large projects and one Postgres database can handle a lot of traffic. My first solution is to offload analytic queries to read-only instances or pull data into a column store for "offline" processing. Just make sure you don't get stuck into some ancient ORM or application framework.
There are several Kubernetes operators that are moving towards more complex topologies, so I think a lot of innovation and progress is happening somewhat outside of core Postgres itself, building on functionality already present within.
1. Full-text search with FTS5
2. Semantic search with sqlite-vec
3. Fuzzy matching with FTS5 trigram tokenizer
4. Bonus: FTS5 bm25() function
Is there anything that's as small and easy to use as FTS5 for indexing text files or JSON documents on the file system?
[1] https://www.philipotoole.com/building-a-highly-available-sea...
Disclaimer: I'm the creator of rqlite, and it's not the only piece of software to make SQLite available over the network.