Skip to main content

A retriever runs one or more queries and returns the top documents. Queries describe which documents match. Retrievers decide how those documents are found and ranked.

Available Retrievers#

RetrieverDescription
$rrfMerges the results of 2 to 10 retrievers with Reciprocal Rank Fusion.
$annFinds the documents whose HYBRID field is closest in meaning to a text.
$standardRuns one query. Use it inside $rrf to set the weight of a query.

Where to Use Retrievers#

A retriever must be the only key of its object. You can use it in two places:

A retriever cannot be used inside a query, such as inside $must, $should, $mustNot, or an $ann filter. $rrf cannot be used inside another $rrf.

Query Options#

Some SEARCH.QUERY options do not work with retrievers:

OptionWith $rrfWith $ann at the root
ORDERBYNot supportedNot supported
SCOREFUNCSupported. It changes the scores of the full-text queries before their results are merged. It does not change $ann results.Not supported
HIGHLIGHTSupportedNot supported

$standard at the root supports all options, the same as a plain query.

Counting and Aggregations#

SEARCH.COUNT and SEARCH.AGGREGATE accept $rrf when it has no $ann retriever. They use every document that matches any of the queries. window and weight do not apply, so the count can be larger than the number of results SEARCH.QUERY returns.

SEARCH.COUNT and SEARCH.AGGREGATE do not support $ann.