bm25.php
Table of Contents
Functions
- bm25() : string
- Score documents with the Best Matching 25 algorithm (Okapi BM25).
Functions
bm25()
Score documents with the Best Matching 25 algorithm (Okapi BM25).
bm25(string $doc[, float|null $k = null ][, float|null $b = null ]) : string
Wraps the ArangoDB AQL scoring function BM25(doc, k, b). The first argument
must be the document variable emitted by a FOR … IN viewName operation, and
the function can only be used together with a SEARCH. Sort descending
by the score to get the most relevant documents first.
AQL arguments are positional: when $b is provided without $k, the helper
fills $k with the official server default (1.2). The Analyzers used for
indexing must have the "frequency" feature enabled (and "norm" for
meaningful length normalization), otherwise the score is 0.
Example AQL usage:
FOR doc IN viewName
SEARCH ...
SORT BM25(doc) DESC
RETURN doc
Parameters
- $doc : string
-
The document variable emitted by
FOR … IN viewName(kept raw). - $k : float|null = null
-
Optional term-frequency calibration,
>= 0.0(server default1.2;0= binary model). - $b : float|null = null
-
Optional text-length scaling in
[0.0, 1.0](server default0.75;1= BM11,0= BM15).
Tags
Return values
string —The formatted AQL expression.