Skip to content

Commit 908c7e0

Browse files
post-review corrections and tabulation
1 parent 8f934dd commit 908c7e0

File tree

8 files changed

+252
-238
lines changed

8 files changed

+252
-238
lines changed

modules/ROOT/pages/expressions/predicates/type-predicate-expressions.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ RETURN $int16param IS :: INTEGER AS isInteger
321321

322322
More information about parameters can be found xref::syntax/parameters.adoc[here].
323323

324+
[NOTE]
325+
The xref:values-and-types/vector.adoc#vector-type[vector-only coordinate types] cannot be used as the numeric type to verify against in type predicate expressions.
326+
324327
[[type-predicate-syntax-variation]]
325328
== Syntactical variations of type predicate expressions
326329

modules/ROOT/pages/functions/index.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ Vector functions allow you to compute the similarity scores of vector pairs.
793793

794794
1.1+| xref::functions/vector.adoc#functions-vector[`vector()`]
795795
| `vector(vectorValue :: STRING \| LIST<INTEGER \| FLOAT>, dimension :: INTEGER, coordinateType :: [INTEGER64, INTEGER32, INTEGER16, INTEGER8, FLOAT64, FLOAT32]) :: VECTOR`
796-
| Constructs a `VECTOR` value with a dimension and coordinate type. label:new[Introduced in Neo4j 2025.xx]
796+
| Constructs a `VECTOR` value. label:new[Introduced in Neo4j 2025.xx]
797797

798798
1.1+| xref::functions/vector.adoc#functions-similarity-cosine[`vector.similarity.cosine()`]
799799
| `vector.similarity.cosine(a :: VECTOR \| LIST<INTEGER \| FLOAT>, b :: VECTOR \| LIST<INTEGER \| FLOAT>) :: FLOAT`
@@ -805,7 +805,7 @@ Vector functions allow you to compute the similarity scores of vector pairs.
805805

806806
1.1+| xref::functions/vector.adoc#functions-vector_dimension_count[`vector_dimension_count()`]
807807
| `(vector :: VECTOR) :: INTEGER`
808-
| Calculates the size of a vector. label:new[Introduced in Neo4j 2025.xx]
808+
| Returns the dimension of a `VECTOR`. label:new[Introduced in Neo4j 2025.xx]
809809

810810
1.1+| xref::functions/vector.adoc#functions-vector_distance[`vector_distance()`]
811811
| `(vector1 :: VECTOR, vector2 :: VECTOR, vectorDistanceMetric :: [EUCLIDEAN, EUCLIDEAN_SQUARED, MANHATTAN, COSINE, DOT, HAMMING]) :: FLOAT`

modules/ROOT/pages/functions/vector.adoc

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,30 @@ Vector functions allow you to construct xref:values-and-types/vector.adoc[`VECTO
1111

1212
.Details
1313
|===
14-
| *Syntax* 3+| `vector(vectorValue[, dimension, coordinateType])`
15-
| *Description* 3+| Constructs a `VECTOR` value with a dimension and coordinate type.
14+
| *Syntax* 3+| `vector(vectorValue, dimension, coordinateType)`
15+
| *Description* 3+| Constructs a `VECTOR` value.
1616
.4+| *Arguments* | *Name* | *Type* | *Description*
17-
| `vectorValue` | `STRING` \| `LIST<INTEGER \| FLOAT>` | The numeric values to create the vector coordinate from.
18-
or `FLOAT` values, or a `STRING` defining the coordinates in the resulting `VECTOR`.
19-
| `dimension` | `INTEGER` | The number of dimensions (coordinates) in the vector.
17+
| `vectorValue` | `STRING` \| `LIST<INTEGER \| FLOAT>` | The numeric values to create the vector coordinates from.
18+
| `dimension` | `INTEGER` | The dimension (number of coordinates) of the vector.
2019
| `coordinateType` | `[INTEGER64, INTEGER32, INTEGER16, INTEGER8, FLOAT64, FLOAT32]` | The type of each coordinate in the vector.
2120
| *Returns* 3+| `VECTOR`
2221
|===
2322

2423
[NOTE]
2524
The `VECTOR` values generated by the `vector()` function can be xref:values-and-types/vector.adoc#store-vector-properties[stored as properties].
2625
As such, the `vector()` function can be used to store the embeddings generated by Neo4j's xref:genai-integrations.adoc[GenAI plugin] as `VECTOR` property values.
27-
`VECTOR` properties can semantically searched by a xref:indexes/semantic-indexes/vector-indexes.adoc[vector index].
28-
29-
26+
`VECTOR` properties can be semantically searched by a xref:indexes/semantic-indexes/vector-indexes.adoc[vector index].
3027

3128
.Considerations
3229
|===
3330

3431
| If a `STRING` is used in `vectorValue`, it must start and end with square brackets (`[]`).
3532
The values inside the brackets must be a number represented in either decimal or scientific notation and must be comma separated.
36-
| `null`, NaN, and infinity values are not allowed in `vectorValue`.
33+
| `null`, `NaN`, and `Infinity` values are not allowed as elements in the `LIST` used as `vectorValue`.
3734
| If `vectorValue` contain elements that are not of the specified `coordinateType`, they will be coerced to that coordinate type if possible.
3835
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`.
39-
| If `dimension` is omitted, it is calculated by taking the size of the `vectorValue`.
40-
For example a `vectorValue` with 1024 elements generates a `VECTOR` value with the dimension `1024`.
4136
| `dimension` must be greater than `0` and less than or equal to `4096`.
42-
| If `coordinateType` is omitted, the type will be determined by Cypher.
43-
If the `LIST` used as `vectorValue` is mixed containing exclusively `INTEGER` values, then the largest of those types will be set as the `coordinateType`.
44-
For example, `LIST<INTEGER64 \| INTEGER32`> generates a `VECTOR` value with a `coordinateType` of `INTEGER64`.
45-
If the `vectorValue` contains both `FLOAT` and `INTEGER` values, then the `coordinateType` will be that of the largest `FLOAT` present in `vectorValue`.
46-
For example, `LIST<INTEGER64 \| FLOAT64`> generates a `VECTOR` value with a `coordinateType` of `FLOAT64`.
47-
| A `null` `vectorValue`, `dimension`, or `coordinateType` will return `null`.
37+
| A `null` `vectorValue` or `dimension` will return `null`.
4838
|===
4939

5040
.vector()
@@ -62,7 +52,7 @@ RETURN vector, valueType(vector) AS vectorType
6252
|===
6353
| vector | vectorType
6454
65-
| [1, 2, 3] | "VECTOR<INTEGER64 NOT NULL>(3) NOT NULL"
55+
| [1, 2, 3] | "VECTOR<INTEGER NOT NULL>(3) NOT NULL"
6656
6757
2+d|Rows: 1
6858
|===
@@ -85,39 +75,21 @@ RETURN vector, valueType(vector) AS vectorType
8575
2+d|Rows: 1
8676
|===
8777
88-
.Construct a `VECTOR` value omitting both `dimension` and `coordinateType`
89-
[source, cypher]
90-
----
91-
WITH vector([1, 2.5, 3]) AS vector
92-
RETURN vector, valueType(vector) AS vectorType
93-
----
94-
95-
.Result
96-
[role="queryresult",options="header,footer",cols="2*<m"]
97-
|===
98-
| vector | vectorType
99-
100-
| [1, 2, 3] | "VECTOR<FLOAT64 NOT NULL>(3) NOT NULL"
101-
102-
2+d|Rows: 1
103-
|===
104-
10578
.`null` values
10679
[source, cypher]
10780
----
10881
RETURN vector(null, 3, FLOAT32) AS nullVectorValue,
109-
vector([1, 2, 3], null, INTEGER8) AS nullDimension,
110-
vector([1, 2, 3], 3, null) AS nullCoordinateType
82+
vector([1, 2, 3], null, INTEGER8) AS nullDimension
11183
----
11284
11385
.Result
114-
[role="queryresult",options="header,footer",cols="3*<m"]
86+
[role="queryresult",options="header,footer",cols="2*<m"]
11587
|===
116-
| nullVectorValue | nullDimension | nullCoordinateType
88+
| nullVectorValue | nullDimension
11789
118-
| null | null | null
90+
| null | null
11991
120-
3+d|Rows: 1
92+
2+d|Rows: 1
12193
|===
12294
12395
=====
@@ -130,8 +102,8 @@ RETURN vector(null, 3, FLOAT32) AS nullVectorValue,
130102
| *Syntax* 3+| `vector.similarity.cosine(a, b)`
131103
| *Description* 3+| Returns a `FLOAT` representing the similarity between the argument vectors based on their cosine.
132104
.3+| *Arguments* | *Name* | *Type* | *Description*
133-
| `a` | `VECTOR` \| `LIST<INTEGER \| FLOAT>` | A list representing the first vector.
134-
| `b` | `VECTOR` \| `LIST<INTEGER \| FLOAT>` | A list representing the second vector.
105+
| `a` | `VECTOR` \| `LIST<INTEGER \| FLOAT>` | A vector or list value representing the first vector.
106+
| `b` | `VECTOR` \| `LIST<INTEGER \| FLOAT>` | A vector or list value representing the second vector.
135107
| *Returns* 3+| `FLOAT`
136108
|===
137109

@@ -161,8 +133,8 @@ The similarity score range from `0` and `1`, with scores closer to `1` indicatin
161133
| *Syntax* 3+| `vector.similarity.euclidean(a, b)`
162134
| *Description* 3+| Returns a `FLOAT` representing the similarity between the argument vectors based on their Euclidean distance.
163135
.3+| *Arguments* | *Name* | *Type* | *Description*
164-
| `a` | `VECTOR` \| `LIST<INTEGER \| FLOAT>` | A list representing the first vector.
165-
| `b` | `VECTOR` \| `LIST<INTEGER \| FLOAT>` | A list representing the second vector.
136+
| `a` | `VECTOR` \| `LIST<INTEGER \| FLOAT>` | A vector or list value representing the first vector.
137+
| `b` | `VECTOR` \| `LIST<INTEGER \| FLOAT>` | A vector or list value representing the second vector.
166138
| *Returns* 3+| `FLOAT`
167139
|===
168140

@@ -246,7 +218,7 @@ This returns the two nearest neighbors.
246218
.Details
247219
|===
248220
| *Syntax* 3+| `vector_dimension_count(vector)`
249-
| *Description* 3+| Calculates the dimension of a `VECTOR`.
221+
| *Description* 3+| Returns the dimension of a `VECTOR`.
250222
.2+| *Arguments* | *Name* | *Type* | *Description*
251223
| `vector` | `VECTOR` | The vector to calculate the dimension of.
252224
| *Returns* 3+| `INTEGER`
@@ -256,7 +228,7 @@ This returns the two nearest neighbors.
256228
|===
257229

258230
| If `vector` is not a xref:values-and-types/vector.adoc[`VECTOR`] value, an error will be thrown.
259-
| Alias to the xref:functions/scalar.adoc#functions-size[`size()`] function.
231+
| The xref:functions/scalar.adoc#functions-size[`size()`] function can also be used to return the dimension of a `VECTOR` value.
260232

261233
|===
262234

@@ -378,7 +350,7 @@ RETURN vector_distance(vector([1.0, 5.0, 3.0, 6.7], 4, FLOAT), vector([5.0, 2.5,
378350
.Details
379351
|===
380352
| *Syntax* 3+| `vector_norm(vector, vectorDistanceMetric)`
381-
| *Description* 3+| Returns a `FLOAT` representing the norm (distance) between the given vector and an origin vector of the same dimension with all coordinates set to zero, calculated using the specified `vectorDistanceMetric`.
353+
| *Description* 3+| Returns a `FLOAT` representing the distance between the given vector and an origin vector, which is a vector with the same dimension with all coordinates set to zero, calculated using the specified `vectorDistanceMetric`.
382354
.4+| *Arguments* | *Name* | *Type* | *Description*
383355
| `vector` | `VECTOR` | A vector for which the norm to the origin vector will be computed.
384356
| `vectorDistanceMetric` | `[EUCLIDEAN, MANHATTAN]` | The vector distance algorithm to calculate the distance by.
@@ -422,7 +394,7 @@ RETURN vector_norm(vector([1.0, 5.0, 3.0, 6.7], 4, FLOAT), EUCLIDEAN) AS norm
422394
.Measure the norm between a vector and an origin vector using the `EUCLIDEAN` distance algorithm
423395
[source, cypher]
424396
----
425-
RETURN vector_norm(Vector([1.0, 5.0, 3.0, 6.7], 4, FLOAT), 'MANHATTAN') AS norm
397+
RETURN vector_norm(vector([1.0, 5.0, 3.0, 6.7], 4, FLOAT), MANHATTAN) AS norm
426398
----
427399
428400
.Result

modules/ROOT/pages/genai-integrations.adoc

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Dump files can be imported for both link:{neo4j-docs-base-uri}/aura/auradb/impor
4242
The embeddings on this are generated using link:https://platform.openai.com/docs/guides/embeddings[OpenAI] (model `text-embedding-ada-002`), producing 1536-dimensional vectors.
4343

4444
[[single-embedding]]
45-
== Generate a single embedding
45+
== Generate a single embedding and store it
4646

4747
Use the `genai.vector.encode()` function to generate a vector embedding for a single value.
4848

@@ -66,23 +66,23 @@ This function sends one API request every time it is called, which may result in
6666
If you want to generate many embeddings at once, use xref:genai-integrations.adoc#multiple-embeddings[].
6767
====
6868

69-
[role=label--new-2025.xx label--enterprise-edition]
70-
[[store-single-embedding-vector]]
71-
=== Store a single embedding as a VECTOR property
69+
70+
[.tabbed-example]
71+
====
72+
[.include-with-Store-embedding-as-a-vector]
73+
======
7274

7375
`genai.vector.encode()` returns a `LIST<FLOAT>`.
74-
To convert and store this value as a xref:values-and-types/vector.adoc[`VECTOR` property type], use the xref:functions/vector.adoc#functions-vector[`vector()`] function.
76+
To convert and store this value as a xref:values-and-types/vector.adoc[`VECTOR` property type (introduced in Neo4j 2025.xx)], use the xref:functions/vector.adoc#functions-vector[`vector()`] function.
77+
Storing `VECTOR` values on an on-prem instance requires Enterprise Edition and using Neo4j's link:{neo4j-docs-base-uri}/operations-manual/current/database-internals/store-formats/#store-format-overview[block format].
7578

7679
.Signature for `vector()` label:function[]
7780
[source]
7881
----
7982
vector(vectorValue :: STRING | LIST<INTEGER | FLOAT>, dimension :: INTEGER, coordinateType :: [INTEGER64, INTEGER32, INTEGER16, INTEGER8, FLOAT64, FLOAT32]) :: VECTOR
8083
----
8184

82-
.Create an embedding from a single property and store it as a `VECTOR` property value
83-
====
84-
85-
.Create an `VECTOR` embedding property for the Godfather
85+
.Create a `VECTOR` embedding property for the Godfather
8686
[source,cypher,role=test-skip]
8787
----
8888
MATCH (m:Movie {title:'Godfather, The'})
@@ -96,24 +96,11 @@ RETURN m.embedding AS embedding
9696
<1> Concatenate the `title` and `plot` of the `Movie` into a single `STRING`.
9797
<2> Create a 1536 dimensional embedding from the `titleAndPlot`.
9898
<3> Store the `propertyVector` as a new `VECTOR` `embedding` property on The Godfather node.
99+
======
99100
100-
.Result
101-
[source, "queryresult"]
102-
----
103-
+----------------------------------------------------------------------------------------------------+
104-
| embedding |
105-
+----------------------------------------------------------------------------------------------------+
106-
| [0.005239539314061403, -0.039358530193567276, -0.0005175105179660022, -0.038706034421920776, ... ] |
107-
+----------------------------------------------------------------------------------------------------+
108-
----
109-
110-
[NOTE]
111-
This result only shows the first 4 of the 1536 numbers in the embedding.
112-
113-
====
114101
115-
[[store-single-embedding-list-float]]
116-
=== Store a single embedding as a LIST<FLOAT> property
102+
[.include-with-Store-embedding-as-a-list]
103+
======
117104

118105
Use the `db.create.setNodeVectorProperty` procedure to store an embedding as a `LIST<FLOAT>` value to a node property.
119106

@@ -137,9 +124,6 @@ db.create.setRelationshipVectorProperty(relationship :: RELATIONSHIP, key :: STR
137124

138125
The embeddings are stored as properties on nodes or relationships with the type `LIST<INTEGER | FLOAT>`.
139126

140-
.Create an embedding from a single property and store it as a `LIST<FLOAT>` property value
141-
====
142-
143127
.Create a `LIST<FLOAT>` embedding property for the Godfather
144128
[source,cypher,role=test-skip]
145129
----
@@ -155,6 +139,10 @@ RETURN m.embedding AS embedding
155139
<2> Create a 1536 dimensional embedding from the `titleAndPlot`.
156140
<3> Store the `propertyVector` as a new `LIST<FLOAT> `embedding` property on The Godfather node.
157141

142+
======
143+
====
144+
145+
158146
.Result
159147
[source, "queryresult"]
160148
----
@@ -168,10 +156,8 @@ RETURN m.embedding AS embedding
168156
[NOTE]
169157
This result only shows the first 4 of the 1536 numbers in the embedding.
170158

171-
====
172-
173159
[[multiple-embeddings]]
174-
== Generate a batch of embeddings
160+
== Generate a batch of embeddings and store them
175161

176162
Use the `genai.vector.encodeBatch()` procedure to generate many vector embeddings with a single API request.
177163
This procedure takes a list of resources as an input, and returns the same number of result rows, instead of a single one.
@@ -202,18 +188,25 @@ Each returned row contains the following columns:
202188
* The `resource` (a `STRING`) is the name of the input resource.
203189
* The `vector` (a `LIST<FLOAT>`) is the generated vector embedding for this resource.
204190

205-
[[store-multiple-embeddings-vector]]
206-
[role=label--new-2025.xx label--enterprise-edition]
207-
=== Store multiple embeddings as VECTOR property values
208191

209-
`genai.vector.encodeBatch()` returns a `LIST<FLOAT>` value.
210-
To convert and store this value as a xref:values-and-types/vector.adoc[`VECTOR` property type], use the xref:functions/vector.adoc#functions-vector[`vector()`] function.
211-
The full function signature can be seen xref:genai-integrations.adoc#store-single-embedding-vector[above].
212192

213-
.Create embeddings from a limited number of properties and store them as `VECTOR` properties
193+
[.tabbed-example]
214194
====
195+
[.include-with-Store-embeddings-as-vectors]
196+
======
215197

216-
[source, cypher, role=test-skip]
198+
`genai.vector.encode()` returns a `LIST<FLOAT>`.
199+
To convert and store this value as a xref:values-and-types/vector.adoc[`VECTOR` property type (introduced in Neo4j 2025.xx)], use the xref:functions/vector.adoc#functions-vector[`vector()`] function.
200+
Storing `VECTOR` values on an on-prem instance requires Enterprise Edition and using Neo4j's link:{neo4j-docs-base-uri}/operations-manual/current/database-internals/store-formats/#store-format-overview[block format].
201+
202+
.Signature for `vector()` label:function[]
203+
[source]
204+
----
205+
vector(vectorValue :: STRING | LIST<INTEGER | FLOAT>, dimension :: INTEGER, coordinateType :: [INTEGER64, INTEGER32, INTEGER16, INTEGER8, FLOAT64, FLOAT32]) :: VECTOR
206+
----
207+
208+
.Create embeddings from a limited number of properties and store them as `VECTOR` properties
209+
[source,cypher,role=test-skip]
217210
----
218211
MATCH (m:Movie WHERE m.plot IS NOT NULL)
219212
WITH m
@@ -228,10 +221,8 @@ CALL db.create.setNodeVectorProperty(moviesList[index], 'embedding', vector) //
228221
<1> xref:functions/aggregating.adoc#functions-collect[Collect] all 20 `Movie` nodes into a `LIST<NODE>`.
229222
<2> Use a xref:expressions/list-expressions.adoc#list-comprehension[list comprehension] (`[]`) to extract the `title` and `plot` properties of the movies in `moviesList` into a new `LIST<STRING>`.
230223
<3> `db.create.setNodeVectorProperty` is run for each `vector` returned by `genai.vector.encodeBatch()`, and stores that vector as a property named `embedding` on the corresponding node.
231-
====
232224

233225
.Create embeddings from a large number properties and store them as `VECTOR` properties
234-
====
235226
[source, cypher, role=test-skip]
236227
----
237228
MATCH (m:Movie WHERE m.plot IS NOT NULL)
@@ -263,18 +254,35 @@ For more information on concurrency in transactions, see xref:subqueries/subquer
263254
This example may not scale to larger datasets, as `collect(m)` requires the whole result set to be loaded in memory.
264255
For an alternative method more suitable to processing large amounts of data, see link:https://neo4j.com/docs/genai/tutorials/embeddings-vector-indexes/[GenAI documentation - Embeddings & Vector Indexes Tutorial -> Create embeddings with cloud AI providers].
265256

266-
====
257+
======
267258
268-
[[store-multiple-embeddings-list-float]]
269-
=== Store multiple embeddings as `LIST<FLOAT>` properties
259+
260+
[.include-with-Store-embeddings-as-lists]
261+
======
270262

271263
Use the `db.create.setNodeVectorProperty` procedure to store an embedding as a `LIST<FLOAT>` value to a node property.
264+
265+
.Signature for `db.create.setNodeVectorProperty` label:procedure[]
266+
[source,syntax]
267+
----
268+
db.create.setNodeVectorProperty(node :: NODE, key :: STRING, vector :: ANY)
269+
----
270+
272271
Use the `db.create.setRelationshipVectorProperty` procedure to store an embedding as a `LIST<FLOAT>` value to a relationship property.
273-
The full procedure signatures can be seen xref:genai-integrations.adoc#store-single-embedding-list-float[above].
274272

275-
.Create embeddings from a limited number of properties and store them as `LIST<FLOAT>` properties
276-
====
273+
.Signature for `db.create.setRelationshipVectorProperty` label:procedure[]
274+
[source,syntax]
275+
----
276+
db.create.setRelationshipVectorProperty(relationship :: RELATIONSHIP, key :: STRING, vector :: ANY)
277+
----
278+
279+
* `node` or `relationship` is the entity in which the new property will be stored.
280+
* `key` (a `STRING`) is the name of the new property containing the embedding.
281+
* `vector` is the object containing the embedding.
282+
283+
The embeddings are stored as properties on nodes or relationships with the type `LIST<INTEGER | FLOAT>`.
277284

285+
.Create embeddings from a limited number of properties and store them as `LIST<FLOAT>` properties
278286
[source, cypher, role=test-skip]
279287
----
280288
MATCH (m:Movie WHERE m.plot IS NOT NULL)
@@ -290,10 +298,8 @@ CALL db.create.setNodeVectorProperty(moviesList[index], 'embedding', vector) //
290298
<1> xref:functions/aggregating.adoc#functions-collect[Collect] all 20 `Movie` nodes into a `LIST<NODE>`.
291299
<2> Use a xref:expressions/list-expressions.adoc#list-comprehension[list comprehension] (`[]`) to extract the `title` and `plot` properties of the movies in `moviesList` into a new `LIST<STRING>`.
292300
<3> `db.create.setNodeVectorProperty` is run for each `vector` returned by `genai.vector.encodeBatch()`, and stores that vector as a property named `embedding` on the corresponding node.
293-
====
294301

295302
.Create embeddings from a large number properties and store them as `LIST<FLOAT>` values
296-
====
297303
[source, cypher, role=test-skip]
298304
----
299305
MATCH (m:Movie WHERE m.plot IS NOT NULL)
@@ -325,6 +331,7 @@ For more information on concurrency in transactions, see xref:subqueries/subquer
325331
This example may not scale to larger datasets, as `collect(m)` requires the whole result set to be loaded in memory.
326332
For an alternative method more suitable to processing large amounts of data, see link:https://neo4j.com/docs/genai/tutorials/embeddings-vector-indexes/[GenAI documentation - Embeddings & Vector Indexes Tutorial -> Create embeddings with cloud AI providers].
327333

334+
======
328335
====
329336

330337
[[ai-providers]]

0 commit comments

Comments
 (0)