$rrf retriever runs several retrievers and merges their results with Reciprocal Rank Fusion
(RRF). Each retriever ranks its own results. A document gets points from every retriever that returns
it, so documents that rank high in several retrievers come first.
Use $rrf for hybrid search, to merge a full-text query with an $ann semantic search. It
also merges full-text queries only, or $ann retrievers only.
Parameters
Scoring
Each retriever that returns a document addsweight / (rankConstant + rank) to its score. rank is the
position of the document in that retriever’s results, starting at 1.
These scores are small numbers. Compare them only with other results of the same query.
Weights
A weight scales how much a retriever adds to the score. All retrievers have a weight of1 by default.
- To set the weight of a query object, wrap it in
$standard. - An
$annretriever takesweightdirectly. - A weight must be
0or greater. With a weight of0, the documents of that retriever stay in the results, but the retriever adds nothing to their score.
Paging
window sets how deep $rrf looks:
- Each retriever contributes up to
windowresults, and the merged list is cut atwindow. - When
windowis not set, it is equal toLIMIT, which is10by default. LIMITcannot be larger thanwindow.- To use
OFFSET, setwindow. A page that starts at or afterwindowis empty.
window on every page so that pages do not overlap.
Examples
Hybrid Search
Merge a full-text query and a semantic search on the same field:- Redis CLI
Weighted Hybrid Search
Give the full-text query twice the weight of the semantic search:- Redis CLI
Full-Text Queries Only
$rrf does not need HYBRID fields:
- Redis CLI
Paging Through Results
Setwindow and keep it the same on every page:
- Redis CLI
SEARCH.QUERY options that work with $rrf, and
Counting and Aggregations for SEARCH.COUNT and
SEARCH.AGGREGATE.