Vector Similarity
Compare a record's numeric embedding fields against a reference vector with cosine similarity, L2 distance, or dot product.
The vector_distance operator builds a per-row vector out of named numeric component fields and compares it with a constant reference vector. Use it to flag records whose embedding is close to (or far from) a known point.
The vector_distance leaf
vector_distance leaf- vector_distance:
dims: [embedding_0, embedding_1, embedding_2]
metric: cosine
reference: [0.1, 0.2, 0.3]
op: gt
value: 0.8Field reference
| Field | Purpose |
|---|---|
dims | The list of numeric per-component field names that form the vector — one scalar field per dimension, not a single array field. |
metric | The distance metric: cosine, l2, or dot. |
reference | The constant reference vector. Its length must match the number of dims. |
op | Comparison operator applied to the computed value. |
value | The threshold to compare against. |
Metrics
cosine— cosine similarity between the row vector and the reference; larger means more similar.l2— Euclidean (straight-line) distance.dot— dot product of the two vectors.
The kernels use the available native backend where supported and fall back to scalar code otherwise. Unlike a Window, vector_distance is stateless — it depends only on the current row, with no cross-batch history.
This is not a nearest-neighbor index
vector_distancecompares each row's vector with one constant reference vector. It is not an ANN (approximate nearest neighbor) index and does not search a corpus of vectors. For nearest-neighbor search over a large embedding collection, use a dedicated vector database.
Where to go next
Updated 11 days ago