Vector Distance Functions and Operators
A vector distance function takes in two vector operands and a distance metric to compute a mathematical distance between those two vectors, based on the distance metric provided. You can optionally use shorthand distance functions and operators instead of their corresponding distance functions.
Distances determine similarity or dissimilarity between vectors.
- Vector Distance Metrics
Measuring distances in a vector space is at the heart of identifying the most relevant results for a given query vector. That process is very different from the well-known keyword filtering in the relational database world. - VECTOR_DISTANCE
VECTOR_DISTANCE
is the main function that you can use to calculate the distance between two vectors. - L1_DISTANCE
L1_DISTANCE
is a shorthand version of theVECTOR_DISTANCE
function that calculates the distance between two vectors. It takes two vectors as input and returns the distance between them as aBINARY_DOUBLE
. - L2_DISTANCE
L2_DISTANCE
is a shorthand version of theVECTOR_DISTANCE
function that calculates the distance between two vectors. It takes two vectors as input and returns the distance between them as aBINARY_DOUBLE
. - COSINE_DISTANCE
COSINE_DISTANCE
is a shorthand version of theVECTOR_DISTANCE
function that calculates the distance between two vectors. It takes two vectors as input and returns the distance between them as aBINARY_DOUBLE
. - INNER_PRODUCT
INNER_PRODUCT
is a shorthand version of theVECTOR_DISTANCE
function that calculates the distance between two vectors. It takes two vectors as input and returns the distance between them as aBINARY_DOUBLE
.
Related Topics
Parent topic: Use SQL Functions for Vector Operations