Skip to content

Commit a85c7b2

Browse files
more
1 parent cdb8a6c commit a85c7b2

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

modules/ROOT/pages/values-and-types/vector.adoc

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,52 @@ Cypher's supports a `VECTOR` type that can be stored as properties on nodes and
66
`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].
77

88

9-
== Create vector type values
9+
== Construct vector type values
1010

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.
1212

13+
.`vector()` function signature
14+
[source]
15+
----
16+
vector(vectorValue :: STRING | LIST<INTEGER | FLOAT>, dimension :: INTEGER, coordinateType :: [INTEGER64, INTEGER32, INTEGER16, INTEGER8, FLOAT64, FLOAT32]) :: VECTOR
17+
----
1318

14-
* vector()
19+
* `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`.
1528

29+
The following expression constructs a three-dimensional vector with integer values:
1630

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+
----
1937

2038

2139
[role=label-enterprise-edition]
2240
== Store vector values as properties
2341

2442

25-
== Vector-only coordinate types
2643

44+
== Vector types, the GenAI plugin, and vector indexes
2745

2846

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

Comments
 (0)