Full-Text Search in Postgres: Skip Elasticsearch for Most Use Cases

Most teams reach for Elasticsearch the moment a product manager says "search." That's usually the wrong call. Elasticsearch is operationally expensive, adds deployment complexity, and requires keeping data in sync with your primary store. Postgres has had a capable full-text search engine for over a decade — and for the majority of applications, it's more than enough.

The core primitives are tsvector and tsquery. A tsvector is a sorted list of normalized lexemes (stemmed tokens) extracted from text. A tsquery is a search expression — terms with boolean operators and optional weights.