Hybrid BM25 vector search
hybrid_bm25_vector_searchCombine BM25 text search with pgvector vector search using Reciprocal Rank Fusion to produce hybrid search results with transparent per-leg rankings.
Instructions
Combine a BM25 search and a pgvector search via Reciprocal Rank Fusion — the canonical v2 pattern ParadeDB documents in the 2025-10-22 'Hybrid Search Missing Manual' blog post. Returns hits as {id, score, bm25_rank, vector_rank}. score is the summed sum(weight * 1.0 / (k + rank)) across both legs; per-leg ranks are surfaced for transparency (either can be NULL if a row only appeared in one leg's top-K). distance_op is the pgvector operator ('<=>'/'<->'/'<#>' — RRF is operator-agnostic). bm25_columns=None searches the whole BM25 index; bm25_columns=["col"] restricts the BM25 leg to a single field. Defaults mirror upstream's demonstrated form (cosine, k=60, equal weights, per_leg_limit=20). Requires the pg_search and pgvector extensions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| k | No | ||
| table | Yes | ||
| schema | Yes | ||
| database | No | Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids. | |
| key_field | Yes | ||
| query_text | Yes | ||
| bm25_weight | No | ||
| distance_op | No | <=> | |
| final_limit | Yes | ||
| bm25_columns | No | ||
| query_vector | Yes | ||
| per_leg_limit | No | ||
| vector_column | Yes | ||
| vector_weight | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |