
Native BM25 hybrid search in AlloyDB and Cloud SQL

Google Cloud is previewing native BM25 full-text search in AlloyDB and Cloud SQL for PostgreSQL 17+, implemented through the open-source pg_textsearch extension created by TigerData. The feature targets hybrid search: vector embeddings understand conceptual meaning but stumble on exact alphanumeric IDs and product SKUs, so applications built on retrieval-augmented generation and data agents often need semantic vector search combined with traditional exact keyword full-text search.
Until now, getting BM25 ranking on AlloyDB or Cloud SQL required adding a separate full-text search backend, which introduced data silos, sync lags, and operational complexity. With the preview, BM25 scoring happens directly inside the database where operational data lives, eliminating the need to provision, manage, or pay for separate systems. The stated benefits are industry-standard keyword ranking via TigerData‘s C-optimized BM25 scoring directly on Postgres tables; no data duplication, ETL pipelines, or synchronization lag from maintaining multiple backends; and, exclusively in AlloyDB, up to 6x and 10x faster vector search queries than standard PostgreSQL using ScaNN and HNSW index types.
The post also explains why BM25 replaces PostgreSQL’s built-in ts_rank for this purpose. At meaningful scale, ts_rank’s ranking quality degrades as the corpus grows; it has no inverse document frequency, so common words carry the same weight as rare ones; and it has no term-frequency saturation, so a document that mentions ‘database’ 50 times outranks one that mentions it once. BM25 provides inverse document frequency (rarer terms matter more), term-frequency saturation (repetition doesn’t dominate), and document length normalization. The post links to a TigerData blog post about how they built a BM25 search engine on PostgreSQL pages.
A concrete example uses a sample cymbal_products table containing uniq_id, product_name, product_description, and a generated product_embedding column, with retail product data including indoor and outdoor plants. You enable pg_textsearch, create the BM25 index on product_description, then query using the <@> special operator, for example searching for ‘cherry tree’. A more negative score indicates a stronger relevance match.
For hybrid search, AlloyDB lets you create both vector and keyword indexes on the same table and merge results with an out-of-the-box hybrid search user-defined function based on Reciprocal Rank Fusion (RRF). The example runs a vector search for ‘trees that grow taller than houses’ and a keyword search for ‘California’, then ranks results in descending order of RRF score, putting ‘California Sycamore’ at the top — showing how semantic intuition and exact keyword matching can be fused in a single query.
Cloud SQL follows the same concept: create an HNSW vector index and a keyword index on the same table, then merge results using a Common Table Expression (CTE) that coalesces the RRF score. The resulting output is identical to the AlloyDB hybrid search results. A demo video is linked at the end of the post.


