COSINE_DISTANCE() function
COSINE_DISTANCE()
is a mathematical function used with vector calculations.
Syntax
COSINE_DISTANCE ({compare-vector, vector-column})
Arguments
Argument | Description | Additional information |
---|---|---|
compare-vector | A comma separated list of floating point numbers to be compared which can be derived using a nested SELECT statement | SELECT statement |
vector-column | Column with vector() datatype in target table to compare against | VECTOR() data type |
Examples
Table CREATE with vector data type
CREATE TABLE products (_id id, description string, dabed vector(768));
INSERT INTO vector data type
INSERT INTO products VALUES({_id}, '{tools_array[i]}', {dabed});
SELECT with COSINE_DISTANCE from vector column
SELECT id, description, cosine_distance([-0.027067707851529, 0.009963636286557, 0.034747183322906], dabed) AS rank FROM products;