FullTextScore (NoSQL query)

APPLIES TO: NoSQL

This function returns a BM25 score value that can only be used in an ORDER BY RANK clause to sort results from highest relevancy to lowest relevancy.

Syntax

FullTextScore(<property_path>, <array_expr>)  

Arguments

Description
property_path The property path to search.
array_expr A nonempty array of string literals.

Return types

Returns a BM25 scoring.

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 of both FullTextScore in the ORDER BY RANK clause, and FullTextContains in the WHERE clause.

SELECT TOP 10 c.text
FROM c
WHERE FullTextContains(c.text, "keyword1")
ORDER BY RANK FullTextScore(c.text, ["keyword1", "keyword2"])

Remarks

  • This function requires enrollment in the Azure Cosmos DB NoSQL Full Text Search preview feature.
  • This function requires a Full Text Index.
  • This function can only be used in an ORDER BY RANK clause, or as an argument in an RRF system function.
  • This function can’t be part of a projection (for example, SELECT FullTextScore(c.text, "keyword") AS Score FROM c is invalid.