sim computes the cosine similarity between two vectors for each row and returns a column of DOUBLE scores. similarity is an equivalent alias.
Signature
Either vector can be a column or a constant, such as one query vector compared with every row.
Rank rows against one query
Return type
DOUBLE, from -1 to 1.
Behavior
- A null vector, a vector with a null element, or a zero-magnitude vector returns null.
- Integer and floating-point elements are supported.
DECIMALelements are not.
Related operations
- Use
neighborsto find the nearest rows within one relation. - Use nearest-neighbor joins to find the closest matches between two relations.
- Use
clusterizeto cluster similar rows.