You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/ROOT/pages/values-and-types/vector.adoc
+35-7Lines changed: 35 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,24 +6,52 @@ Cypher's supports a `VECTOR` type that can be stored as properties on nodes and
6
6
`VECTOR` properties can be utilized for efficient semantic retrieval with the Neo4j's xref:indexes/semantic-indexes/vector-indexes.adoc[vector indexes] and xref:genai-integrations.adoc[GenAI plugin].
7
7
8
8
9
-
== Create vector type values
9
+
== Construct vector type values
10
10
11
-
To create a `VECTOR` type value, use the ``
11
+
To construct a `VECTOR` type value, use the xref:functions/vector.adoc#functions-vector[`vector()`] function.
* `vectorValue`: a `LIST` of either `INTEGER` or `FLOAT` values, or a `STRING` (the `STRING` must start and end with square brackets (`[]`).
20
+
The values inside the brackets must be a number represented in either decimal or scientific notation and must be comma separated).
21
+
The `vectorValue` must be of the same length as the given `dimension` and contain values of the corresponding `coordinateType`.
22
+
`null`, NaN, and infinity values are not allowed.
23
+
* `dimension`: an `INTEGER` (with a value greater than `0 and less than or equal to `4096`) specifying the number of coordinates the `VECTOR` value contains.
24
+
For example a `VECTOR` with a dimension of `3` has three values, which might represent vector embeddings.
25
+
* `coordinateType`: a vector-only coordinate `INTEGER` or `FLOAT` type, determining the data type for each of the values in `vectorValue`.
26
+
If `vectorValue` contain elements that are not of the specified coordinate type, they will be coerced to that coordinate type if possible.
27
+
This includes the potential of lossy conversion in cases where a larger type, e.g. `INTEGER64` does not fit into the specified type, e.g. `FLOAT32`.
15
28
29
+
The following expression constructs a three-dimensional vector with integer values:
16
30
17
-
* dimension
18
-
* Coordinates
31
+
.Construct a `VECTOR` value
32
+
[source, cypher]
33
+
----
34
+
WITH vector([1,2,3], 3, INTEGER) AS vector
35
+
RETURN vector, valueType(vector)
36
+
----
19
37
20
38
21
39
[role=label-enterprise-edition]
22
40
== Store vector values as properties
23
41
24
42
25
-
== Vector-only coordinate types
26
43
44
+
== Vector types, the GenAI plugin, and vector indexes
27
45
28
46
29
-
==
47
+
== Vectors and lists
48
+
49
+
50
+
Since Vectors are described as having multiple dimensions, they look a bit like the constructed value type LIST<...>. However, all vector operations operate on the entire vector. Operations on individual components of a vector instance are not defined. We therefore conclude that vectors are predefined value types.
51
+
52
+
53
+
54
+
55
+
== Vector supertype and vector coordinate types
56
+
57
+
Whilst it is not possible to store a typeless, dimensionless vector, it is possible to use that type in a type predicate expression for example; RETURN x IS :: VECTOR which should evaluate to true as long as x is a vector, regardless of its coordinate type or dimension. Due to this, we consider VECTOR to be a supertype of all VECTOR types. This logic continues for vectors that define only a type or a dimension, a VECTOR with only a dimension represents all vectors of that dimension regardless of the type, and a VECTOR with only a type represents all vectors of that type regardless of the dimension.
0 commit comments