From 74034f434ba5554adcf357ef705b676636762896 Mon Sep 17 00:00:00 2001 From: DavIvek Date: Tue, 7 Oct 2025 11:56:42 +0200 Subject: [PATCH 1/2] add cosine similarity function --- pages/querying/vector-search.mdx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pages/querying/vector-search.mdx b/pages/querying/vector-search.mdx index 50ce52e36..26832d83a 100644 --- a/pages/querying/vector-search.mdx +++ b/pages/querying/vector-search.mdx @@ -160,6 +160,16 @@ for the metric is `l2sq` (squared Euclidean distance). | `sorensen` | Sørensen-Dice coefficient | | `jaccard` | Jaccard index | +### Cosine similarity function + +You can calculate cosine similarity directly in queries using the `vector_search.cosine_similarity` function. This is useful when you need to compute similarity between vectors without creating a vector index. + +{

Usage:

} + +```cypher +RETURN vector_search.cosine_similarity([1.0, 2.0], [1.0, 3.0]) AS similarity; +``` + ### Scalar type Properties are stored as 64-bit values in the property store. However, for efficiency, vector elements in the vector index are stored using 32-bit values by default. From 275de004fc45262b0451cd123cb525825cf55acb Mon Sep 17 00:00:00 2001 From: Matea Pesic <80577904+matea16@users.noreply.github.com> Date: Tue, 7 Oct 2025 13:31:19 +0200 Subject: [PATCH 2/2] Apply suggestions from code review --- pages/querying/vector-search.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/querying/vector-search.mdx b/pages/querying/vector-search.mdx index 26832d83a..1e5ab1c62 100644 --- a/pages/querying/vector-search.mdx +++ b/pages/querying/vector-search.mdx @@ -160,9 +160,9 @@ for the metric is `l2sq` (squared Euclidean distance). | `sorensen` | Sørensen-Dice coefficient | | `jaccard` | Jaccard index | -### Cosine similarity function +### Cosine similarity -You can calculate cosine similarity directly in queries using the `vector_search.cosine_similarity` function. This is useful when you need to compute similarity between vectors without creating a vector index. +You can calculate cosine similarity directly in queries using the `vector_search.cosine_similarity()` function. This is useful when you need to compute similarity between vectors without creating a vector index. {

Usage:

}