ngramMatch.php
Table of Contents
Functions
- ngramMatch() : string
- Match documents whose attribute has an n-gram similarity above a threshold.
Functions
ngramMatch()
Match documents whose attribute has an n-gram similarity above a threshold.
ngramMatch(string $path, string $target, string $analyzer[, float|null $threshold = null ]) : string
Wraps the ArangoDB AQL function NGRAM_MATCH(path, target, threshold, analyzer).
The n-grams of both the attribute and the target are produced by the given
Analyzer (use an ngram Analyzer with preserveOriginal: false and min
equal to max, with the "position" and "frequency" features enabled).
Argument order notice — in AQL the optional threshold sits before the
mandatory analyzer; PHP forbids a required parameter after an optional one,
so this helper takes the analyzer third and the optional threshold
last, then re-orders the emitted AQL arguments. When $threshold is
null the three-argument AQL form is emitted (server default: 0.7).
Example AQL usage:
NGRAM_MATCH(doc.text, "quick fox", "bigram") // threshold defaults to 0.7
NGRAM_MATCH(doc.text, "quick blue fox", 0.4, "bigram")
Parameters
- $path : string
-
Attribute path expression to test (kept raw).
- $target : string
-
String to compare against (emitted as a quoted string literal).
- $analyzer : string
-
Name of the
ngramAnalyzer (emitted as a quoted string literal). - $threshold : float|null = null
-
Optional similarity threshold in
[0.0, 1.0](server default0.7).
Tags
Return values
string —The formatted AQL expression.