Syntax\n------\n\nVEC_DISTANCE_COSINE(v, s)\n\nDescription\n-----------\n\nVEC_Distance_Cosine is an SQL function that calculates the Cosine distance between two (not necessarily normalized) vectors.\n\nVectors must be of the same length. A distance between two vectors of different lengths is not defined, and VEC_Distance_Cosine will return NULL in such cases.\n\nIf the vector index was not built for the cosine function (see CREATE TABLE with Vectors), the index is not used — a full table scan is performed instead. The VEC_DISTANCE function is a generic function that behaves either as VEC_DISTANCE_EUCLIDEAN or VEC_DISTANCE_COSINE, depending on the underlying index type.\n\nExamples\n--------\n\nSELECT VEC_DISTANCE_COSINE(vec_fromtext('[1,2,3]'), vec_fromtext('[3,5,7]'));\n+-----------------------------------------------------------------------+\n| VEC_DISTANCE_COSINE(vec_fromtext('[1,2,3]'), vec_fromtext('[3,5,7]')) |\n+-----------------------------------------------------------------------+\n|                                                   0.00258509695694209 |\n+-----------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_distance_cosine