rerank() query method.
Basic usage
Callrerank() after topk():
model— The reranking model to use (e.g.cohere/rerank-v3.5). Defaults to a built-in model if omitted.query— The query text the cross-encoder scores each document against. If omitted, may be inferred from the filter stage (e.g.match()).fields— Document fields to include when reranking. The reranker concatenates these and scores them against the query. Restricts which text is sent to the model.topk_multiple— Multiple of top-k to consider for reranking. Withtopk(10)andtopk_multiple=2, the reranker receives 20 candidates and returns the top 10. Use a higher value to improve recall at the cost of latency.
- Retrieve top-k candidates using ANN or BM25.
- Rerank the top
k × Nresults. - Return the highest-scoring documents after reranking.
Example: Improving lexical search results
Query:Step 1: BM25 keyword search
Step 2: Apply reranking
_rerank_score field representing
its semantic relevance.
When to use reranking
Reranking is recommended when:- Using BM25 for keyword retrieval
- Using ANN for dense vector search
- Combining multiple retrieval strategies (hybrid search)
- Precision at top-k is critical (e.g., RAG, support search, documentation search)