BM25
The BM25 scoring function uses the Best Matching 25 (BM25) algorithm to sort documents based on their relevance.
Syntax
BM25(doc, k, b) → score
doc
(document): Specified by FOR ... IN viewName
k
(number, optional): Adjusts the text term frequency scaling. Defaults to 1.2
.
b
(number, optional): Determines the scaling by the total text length. Defaults to 0.75
.
Examples
The following example returns documents sorted by relevance using the BM25 scoring function with default settings:
FOR doc IN viewName
SEARCH ...
SORT BM25(doc) DESC
RETURN doc
This example demonstrates sorting by relevance with a double-weighted term frequency and full text length normalization:
FOR doc IN viewName
SEARCH ...
SORT BM25(doc, 2.4, 1) DESC
RETURN doc