For AI agents: this page is also available as Markdown at /docs/hybrid-search.md. Every docs page is: add .md to its URL. llms.txt lists them all.
Hybrid search
Hybrid search runs a keyword query and a vector search together and merges the results. The two fail in opposite ways: keywords miss paraphrases and synonyms, and vectors miss exact identifiers, rare names and part numbers. With both, "waterproof jacket for hiking" matches on meaning and "XJ-4421" still finds the exact product.
There are two ways to combine them, both on POST /v1/collections/{collection}/search with language: "es":
- rank fusion, which ranks each source on its own and merges the lists with reciprocal rank fusion (RRF) or weighted linear fusion, written as Elasticsearch
rrfandlinearretrievers, and - summed scores, where a
knnsection sits beside a textqueryand the two scores are added.
The same requests work on the Elasticsearch- and OpenSearch-compatible APIs, and the turbopuffer-compatible API has its own RRF multi-query.
#Fusion
A fusion takes several retrievers, each producing a ranked list from its own query, and merges the lists. On /v1, the retriever goes inside query, and the request's filters apply to every retriever:
curl -s https://api.warpsearch.io/v1/collections/books/search \
-H "Authorization: Bearer $WARPSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"language": "es",
"query": {
"retriever": {
"rrf": {
"retrievers": [
{ "standard": { "query": { "match": { "title_t": "dune" } } } },
{ "knn": { "field": "embedding_v", "query_vector": [0.75, 0.15, 0.10], "k": 100, "num_candidates": 200 } }
],
"rank_constant": 60,
"rank_window_size": 100
}
}
},
"filters": [{ "term": { "kind_s": "fiction" } }],
"limit": 10,
"fields": ["id", "title_t"]
}'
curl -s https://api.warpsearch.io/compat/es/books/_search \
-H "Authorization: Bearer $WARPSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"retriever": {
"rrf": {
"retrievers": [
{ "standard": { "query": { "match": { "title_t": "dune" } } } },
{ "knn": { "field": "embedding_v", "query_vector": [0.75, 0.15, 0.10], "k": 100, "num_candidates": 200 } }
],
"filter": { "term": { "kind_s": "fiction" } },
"rank_constant": 60,
"rank_window_size": 100
}
},
"size": 10,
"_source": ["title_t"]
}'
A hybrid query with the search pipeline in the body (stored pipelines are not supported). Only the score-ranker-processor (RRF) is accepted:
curl -s https://api.warpsearch.io/compat/opensearch/books/_search \
-H "Authorization: Bearer $WARPSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": {
"hybrid": {
"queries": [
{ "match": { "title_t": "dune" } },
{ "knn": { "embedding_v": { "vector": [0.75, 0.15, 0.10], "k": 100 } } }
],
"filter": { "term": { "kind_s": "fiction" } },
"pagination_depth": 100
}
},
"search_pipeline": {
"phase_results_processors": [
{ "score-ranker-processor": { "combination": { "technique": "rrf", "rank_constant": 60 } } }
]
},
"size": 10
}'
A multi-query with rerank_by RRF:
curl -s https://api.warpsearch.io/compat/turbopuffer/v2/namespaces/books/query \
-H "Authorization: Bearer $WARPSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"queries": [
{ "rank_by": ["title_t", "BM25", "dune"], "filters": ["kind_s", "Eq", "fiction"], "top_k": 100 },
{ "rank_by": ["embedding_v", "ANN", [0.75, 0.15, 0.10]], "filters": ["kind_s", "Eq", "fiction"], "top_k": 100 }
],
"rerank_by": ["RRF", { "rank_constant": 60 }],
"limit": 10
}'
| Field | Meaning |
|---|---|
retrievers | The ranked inputs: standard (a query, with its own filter and, under rrf, sort) or knn. Wrap one as {"retriever": ..., "weight": w} to weight it. |
filter | Shared by every retriever and ANDed with each one's own filter. The request's filters on /v1 do the same. |
rank_constant | RRF smoothing constant, at least 1. Defaults to 60. |
rank_window_size | How many results each retriever contributes. Defaults to 10, and must be at least limit. |
The fusion is rrf or linear. Retrievers do not nest: a fusion's retrievers are standard or knn. The OpenSearch and turbopuffer forms are described in OpenSearch and turbopuffer compatibility.
#Reciprocal rank fusion
With RRF, a document scores weight / (k + rank) for every source that returned it, summed over sources, with ranks starting at 1. Only ranks count, so BM25 scores and cosine similarities never need to share a scale, and RRF works well as a default without tuning.
A document ranked first by both retrievers above scores 1/61 + 1/61. A document found by only one source still appears, with a smaller score.
#Weights
Weights scale a source's contribution without changing which candidates it brings:
{
"language": "es",
"query": {
"retriever": {
"rrf": {
"retrievers": [
{ "retriever": { "standard": { "query": { "match": { "title_t": "dune" } } } }, "weight": 1 },
{ "retriever": { "knn": { "field": "embedding_v", "query_vector": [0.75, 0.15, 0.10], "k": 100 } }, "weight": 2 }
],
"rank_window_size": 100
}
}
}
}
Weights must be finite and at least 0, and at least one must be above 0. A weight of 0 switches the retriever off: it is not run, and its documents do not reach the result. You can use this to toggle a source from configuration without rewriting the request. The OpenSearch score ranker takes parameters.weights (summing to 1), and turbopuffer RRF takes weights.
#Linear fusion
Linear fusion combines scores instead of ranks. Each source's scores are rescaled to the range 0 to 1 over its own result list, then summed with the weights:
normalized(d) = (score(d) - min) / (max - min)
fused(d) = sum over sources of weight * normalized(d)
{
"language": "es",
"query": {
"retriever": {
"linear": {
"retrievers": [
{ "retriever": { "standard": { "query": { "match": { "title_t": "dune" } } } }, "weight": 0.3, "normalizer": "minmax" },
{ "retriever": { "knn": { "field": "embedding_v", "query_vector": [0.75, 0.15, 0.10], "k": 100 } }, "weight": 0.7, "normalizer": "minmax" }
],
"rank_window_size": 100
}
}
}
}
min and max are the lowest and highest scores in that source's list, so its best document gets 1 and its worst gets 0. A source that did not return a document contributes 0 to it. If all scores in a list are equal, every document in it gets 1.
minmax is the only normalizer, and it must be set, on each retriever or once on linear. Linear fusion is available in the WarpSearch and Elasticsearch forms; the OpenSearch normalization-processor is not supported.
Prefer RRF when score distributions are unknown or unstable, or when a source is sorted by a field. Prefer linear when score magnitudes carry information you want to keep, such as a clear winner in one source beating a near tie in another, and you can tune weights against relevance judgments. Min-max is sensitive to outliers and to the list size, so retune weights after changing a source's rank_window_size. Every retriever under linear fusion must rank by relevance score.
#Pools, filters and facets
| Topic | Behavior |
|---|---|
| Pool size | A document outside a retriever's window cannot contribute from that retriever. Size rank_window_size for the recall your page size needs; 50 to 200 is a common range. |
| Paging | offset (from) pages within the union of the windows and does not enlarge them. Deep paging needs a larger rank_window_size. |
| Filters | The fusion-level filter (or filters on /v1) applies to every retriever, and a retriever can add its own on top. Filters apply inside the vector search, not afterwards. post_filters (post_filter) is not supported with fusion. |
| Facets | Aggregations count every document a retriever matches (its query within its filters, or a kNN retriever's k nearest), as Elasticsearch does, not only the fused page. |
| Sorting and diversity | A fused search cannot also be sorted, cut by min_score or collapsed, and retrievers inside a fusion cannot use collapse. To keep one hit per entity, use Nearest groups on a plain kNN search. |
#Summed scores
Instead of a fusion, you can put a knn section beside the text query. A document matches if either part matches, and its score is the sum of the two scores, each times its boost. This is how Elasticsearch scores a knn section next to a query:
curl -s https://api.warpsearch.io/v1/collections/books/search \
-H "Authorization: Bearer $WARPSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"language": "es",
"query": {
"query": { "match": { "title_t": { "query": "dune", "boost": 0.4 } } },
"knn": {
"field": "embedding_v",
"query_vector": [0.75, 0.15, 0.10],
"k": 50,
"num_candidates": 200,
"boost": 0.6,
"filter": { "term": { "kind_s": "fiction" } }
}
},
"limit": 10
}'
curl -s https://api.warpsearch.io/compat/es/books/_search \
-H "Authorization: Bearer $WARPSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": { "match": { "title_t": { "query": "dune", "boost": 0.4 } } },
"knn": {
"field": "embedding_v",
"query_vector": [0.75, 0.15, 0.10],
"k": 50,
"num_candidates": 200,
"boost": 0.6,
"filter": { "term": { "kind_s": "fiction" } }
},
"size": 10
}'
The knn query clause works inside a bool query, beside must and should clauses:
curl -s https://api.warpsearch.io/compat/opensearch/books/_search \
-H "Authorization: Bearer $WARPSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": {
"bool": {
"should": [
{ "match": { "title_t": { "query": "dune", "boost": 0.4 } } },
{ "knn": { "embedding_v": { "vector": [0.75, 0.15, 0.10], "k": 50, "boost": 0.6,
"filter": { "term": { "kind_s": "fiction" } } } } }
]
}
},
"size": 10
}'
Vector scores are WarpSearch similarity scores (raw cosine or dot product), not Elasticsearch's rescaled values, so boosts tuned on Elasticsearch may need retuning. A knn section's own filter restricts only its candidates. To filter the keyword side too, put the filter in filters on /v1, or inside the query as well.
On Solr, q={!knn f=embedding_v topK=50}[0.75, 0.15, 0.10] runs a vector search with fq filters applied before the neighbors are chosen, but there is no Solr form that combines it with a keyword query. See Elasticsearch, OpenSearch and Solr.
Summed scores are not rank fusion. For RRF or normalized linear combination, use an rrf or linear retriever (Fusion).
#Recipes
| Goal | Setup |
|---|---|
| Sensible default | RRF with rank_constant 60, equal weights, rank_window_size 100. |
| Semantic-heavy (natural-language questions) | RRF with weights such as keyword 1, vector 2, or linear with 0.3 / 0.7. |
| Keyword-heavy (product search, codes, names) | RRF with weights such as keyword 2, vector 1, or linear with 0.7 / 0.3. |
| Restrict to a segment of data | Put the condition in filters (or the fusion filter) so every retriever obeys it. |
| Turn off vectors for exact-match lookups | Set the kNN retriever's weight to 0 from your own configuration. |
| Boost a field only on the keyword side | Keep boosts in the keyword retriever's query, not in weights. |
Start with the defaults, collect a handful of queries with known good answers, and change one thing at a time.
#Measure recall
Approximate vector search can miss true neighbors. To see whether that affects your hybrid results, run the same request twice, with "exact": true on the knn in one of them. If the fused lists barely differ, approximate search is costing you nothing and the defaults are fine. If they differ a lot, raise ivf.nprobe or num_candidates (see Tune recall and latency), or rank_window_size if relevant documents fall just outside the fused window.
#Reranking
WarpSearch does not host models, so cross-encoder and other reranker models, including Elasticsearch's text_similarity_reranker retriever, are not available. Rerank in your application: retrieve the top 50 to 100 fused results, send them to your reranker, and keep the best few. Because fusion already blends keywords and meaning, the reranker only has to reorder a short list.
#Not supported
Not supported: the Elasticsearch
text_similarity_reranker,rescorer,pinned,ruleanddiversifyretrievers, nestedrrforlinearretrievers, the OpenSearchnormalization-processorand stored search pipelines, and OpenSearchneuralandneural_sparsequeries. They return400 unsupported_feature(see Query languages).
Coming soon: sparse vectors for learned sparse retrieval (for example SPLADE) and
rank_featuresfields, which suit learned token weights and static signals such as popularity. They are in development, with no release date. Once available, a sparse source can join the same fusion as the keyword and dense sources.
For the vector side, see Vector search and Multi-vector fields.