Hybrid BM25 vector search
hybrid_bm25_vector_searchCombines BM25 keyword search and pgvector semantic search with Reciprocal Rank Fusion to return one ranked result set, solving relevance gaps when either method alone misses matches.
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.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"schema": "<schema>",
"table": "<table>",
"query_text": "<query_text>",
"query_vector": "<query_vector>",
"key_field": "<key_field>",
"vector_column": "<vector_column>",
"final_limit": "<final_limit>"
},
"name": "hybrid_bm25_vector_search"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| k | No | ||
| table | Yes | ||
| schema | Yes | ||
| database | No | Optional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected. | |
| 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 |