approxNearL2.php
Table of Contents
Functions
- approxNearL2() : string
- Return the approximate L2 (Euclidean) distance between two vectors, accelerated by a vector index.
Functions
approxNearL2()
Return the approximate L2 (Euclidean) distance between two vectors, accelerated by a vector index.
approxNearL2(string|int $x, string|int $y[, int|null $nProbe = null ]) : string
This helper wraps the ArangoDB AQL function APPROX_NEAR_L2(x, y).
One of the two operands must reference a document attribute covered by a
VectorIndex created with the
"l2" metric; the other is the query vector. The closer the returned value
is to 0, the more similar the vectors are.
Because smaller is more similar, you sort in ascending order to get the
nearest neighbours first — which is exactly what aqlVectorSearch()
does for the l2 metric.
Requires ArangoDB started with the experimental vector index feature.
Example AQL usage:
FOR doc IN items
SORT APPROX_NEAR_L2(doc.embedding, @query) ASC
LIMIT 10
RETURN doc
Parameters
- $x : string|int
-
First operand — the stored attribute or the query vector.
- $y : string|int
-
Second operand — the query vector or the stored attribute.
- $nProbe : int|null = null
-
Optional number of neighbouring centroids to probe (higher = more accurate, slower).
Tags
Return values
string —The formatted AQL expression.