共用方式為


RRF - Cosmos DB 中的查詢語言 (在 Azure 和 Fabric 中)

函數會 RRF 結合其他函數提供的兩個或多個分數,傳回融合分數。

語法

RRF(<function1>, <function2>, ..., <weights>)

Arguments

Description
function1 評分函式,例如 VectorDistance 或 FullTextScore。
function2 評分函式,例如 VectorDistance 或 FullTextScore。
weights 定義每個評分函數重要性加權的數字陣列。

傳回類型

傳回代表融合分數的數值。

範例

本節包含如何使用此查詢語言建構的範例。

混合搜尋 (向量相似性 + BM25)

在此範例中,混合式搜尋結合了 FullTextScore 和 VectorDistance。

SELECT TOP 10 *
FROM c
ORDER BY RANK RRF(FullTextScore(c.text, "keyword"), VectorDistance(c.vector, [1,2,3]))
-- Example result not available (see documentation)

在此範例中,混合式搜尋會針對評分函式使用權重。

SELECT TOP 10 *
FROM c
ORDER BY RANK RRF(FullTextScore(c.text, "keyword"), VectorDistance(c.vector, [1,2,3]), [2,1])
-- Example result not available (see documentation)

與兩個 FullTextScore 函數的融合

在此範例中,會融合兩個 FullTextScore 函式。

SELECT TOP 10 *
FROM c
ORDER BY RANK RRF(FullTextScore(c.text, "keyword1"), FullTextScore(c.text, "keyword2"))
-- Example result not available (see documentation)

與兩個 VectorDistance 函數融合

在此範例中,兩個 VectorDistance 函數會融合。

SELECT TOP 5 *
FROM c
ORDER BY RANK RRF(VectorDistance(c.vector1, [1,2,3]), VectorDistance(c.vector2, [2,2,4]))
-- Example result not available (see documentation)

備註

  • 此功能需要註冊 Azure Cosmos DB NoSQL 全文檢索搜尋功能。
  • 混合式搜尋也需要在 Azure Cosmos DB NoSQL 向量搜尋中註冊。
  • 此功能需要全文索引。
  • 此函式只能在子句中使用 ORDER BY RANK ,而且無法在 ORDER BY 其他屬性路徑上結合使用。
  • 此函式不能是投影的一部分 (例如, SELECT FullTextScore(c.text, "keyword") AS Score FROM c 無效)。