Edit

Share via


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 of the specified terms.

Syntax

FullTextScore(<property_path>, <string_expr1>, <string_expr2>, ... )  

Arguments

Description
property_path The property path to search.
string_expr1 The first term to find.
string_expr2 The second term to find.

Return types

Returns a BM25 scoring that can be used with ORDER BY RANK or RRF.

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.