This is a read-only copy of the MariaDB Knowledgebase generated on 2024-12-18. For the latest, interactive version please visit https://mariadb.com/kb/.

VEC_DISTANCE_COSINE

MariaDB starting with 11.6

Vectors were introduced in MariaDB 11.6 Vector Preview.

Syntax

VEC_DISTANCE_COSINE(v, s)

Description

VEC_Distance_Cosine is an SQL function that calculates a Cosine distance between two vectors.

Example

select vec_distance_cosine(vec_fromtext('[1,2,3]'), vec_fromtext('[3,5,7]'));
+-----------------------------------------------------------------------+
| vec_distance_cosine(vec_fromtext('[1,2,3]'), vec_fromtext('[3,5,7]')) |
+-----------------------------------------------------------------------+
|                                                   0.00258509695694209 |
+-----------------------------------------------------------------------+
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.