pg_textsearch is a PostgreSQL extension developed by Timescale that brings BM25 relevance-ranked full-text search directly into Postgres. While PostgreSQL's built-in tsvector and pg_trgm provide basic text search capabilities, they use TF-IDF style ranking that degrades at scale and lacks the sophisticated relevance scoring that users expect from modern search experiences. pg_textsearch adds BM25 — the same ranking algorithm powering Elasticsearch and Apache Lucene — as a native Postgres operator, enabling search-engine quality results without deploying and maintaining a separate search infrastructure.
The extension introduces a clean operator syntax where you simply write ORDER BY content <@> 'search terms' to get BM25-ranked results. Block-Max WAND optimization ensures efficient top-k query execution even over large tables, and the implementation integrates with PostgreSQL's query planner for optimal performance. For developers building RAG pipelines on PostgreSQL — already using pgvector for semantic similarity search — pg_textsearch adds the keyword-based relevance layer that makes hybrid search possible within a single database, eliminating the need to synchronize data between Postgres and Elasticsearch.
Released under the PostgreSQL license by Timescale, a well-funded infrastructure company, the extension has gained rapid attention with over 3,500 GitHub stars and a Hacker News launch that hit 180 points. The combination of pgvector for vector similarity and pg_textsearch for BM25 ranking gives PostgreSQL a complete hybrid search stack that rivals purpose-built search engines — an increasingly attractive proposition as teams look to reduce operational complexity by consolidating on fewer database systems.