ORDER BY RANK (NoSQL query)

APPLIES TO: NoSQL

The optional ORDER BY RANK clause sorts scoring functions by their rank. It's used specifically for scoring functions like VectorDistance, FullTextScore, and RRF.

Syntax

ORDER BY RANK <scoring function>

Arguments

Description
<scoring function> Specifies a scoring function like VectorDistance, FullTextScore, or RRF.

Note

For more information on scalar expressions, see scalar expressions.

Examples

This is a simple example showing how to use FullTextScore with ORDER BY RANK to sort from highest relevancy to lowest relevancy.

SELECT TOP 10 c.text
FROM c
ORDER BY RANK FullTextScore(c.text, ["keyword"])

This next example shows use RRF in the ORDER BY RANK clause to combine VectorDistance similarity scores with FullTextScore BM25 scores to execute a hybrid search

SELECT TOP 10 c.text
FROM c
WHERE FullTextContains(c.text, "keyword1")
ORDER BY RANK RRF(FullTextScore(c.text, ["keyword1", "keyword2"]), VectorDistance(c.vector, [1,2,3]))

Remarks