Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4a9e924
initial
JPryce-Aklundh May 27, 2025
cdb8a6c
vector ordering table
JPryce-Aklundh May 28, 2025
a85c7b2
more
JPryce-Aklundh May 30, 2025
4edc094
significant update to vector type page
JPryce-Aklundh Jun 2, 2025
106472f
progress on functions, genai procedures etc
JPryce-Aklundh Jun 3, 2025
34d821f
slice and dice
JPryce-Aklundh Jun 4, 2025
85b16cd
type predicate expressions
JPryce-Aklundh Jun 5, 2025
f3200da
Merge branch 'cypher-25' into vector_type
JPryce-Aklundh Jun 5, 2025
2b42ccf
more edits
JPryce-Aklundh Jun 5, 2025
f86aa96
minor changes
JPryce-Aklundh Jun 5, 2025
6266c80
function update
JPryce-Aklundh Jun 5, 2025
8f934dd
vector page cleanup
JPryce-Aklundh Jun 5, 2025
908c7e0
post-review corrections and tabulation
JPryce-Aklundh Jun 9, 2025
2a9e44b
post review updates and rewording
JPryce-Aklundh Jun 10, 2025
3e1375e
Merge branch 'dev' into vector_type
stefano-ottolenghi Jun 17, 2025
b3bd7a5
minor fixes and additions entries
JPryce-Aklundh Jun 25, 2025
107adf2
Merge branch 'vector_type' of https://github.com/JPryce-Aklundh/docs-…
JPryce-Aklundh Jun 25, 2025
954098d
conflict fix
JPryce-Aklundh Sep 16, 2025
9c4107f
cypher 25 information
JPryce-Aklundh Sep 16, 2025
df674b5
add vectors to gql appendix
JPryce-Aklundh Sep 17, 2025
b12a42a
fallback map and results (not genai plugin)
JPryce-Aklundh Sep 29, 2025
81e7f84
Merge branch 'dev' into vector_type
JPryce-Aklundh Sep 29, 2025
3b77b69
query fix
JPryce-Aklundh Sep 29, 2025
45ee98d
All except genai integrations
stefano-ottolenghi Oct 1, 2025
9f70ea0
revise pages
stefano-ottolenghi Oct 2, 2025
b58ad2b
final
stefano-ottolenghi Oct 2, 2025
599cfe3
Fix genai page dumps for block format
stefano-ottolenghi Oct 3, 2025
95cb626
fix examples and polish
stefano-ottolenghi Oct 4, 2025
0ecbdc9
remarks on lists
stefano-ottolenghi Oct 4, 2025
ab10c91
Remove mistaken file
stefano-ottolenghi Oct 4, 2025
fcd52a2
note float32 arithmetic
stefano-ottolenghi Oct 6, 2025
0e55e97
Merge branch 'dev' into vector_type
stefano-ottolenghi Oct 6, 2025
2eae0fb
fix examples
stefano-ottolenghi Oct 8, 2025
433969c
Merge branch 'dev' into vector_type
stefano-ottolenghi Oct 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/ROOT/content-nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
** xref::values-and-types/spatial.adoc[]
** xref::values-and-types/lists.adoc[]
** xref::values-and-types/maps.adoc[]
** xref::values-and-types/vector.adoc[]
** xref:values-and-types/graph-references.adoc[]
** xref::values-and-types/working-with-null.adoc[]
** xref::values-and-types/casting-data.adoc[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,122 @@ RETURN val, val IS :: INTEGER AS isInteger
2+d|Rows: 4
|===

[role=label-new-2025.xx]
[[type-predicate-vector]]
=== VECTOR values

Whilst it is not possible to store a xref:values-and-types/vector.adoc[`VECTOR`] value without a coordinate type and dimension, it is possible to use the `VECTOR` supertype (encompassing all combinations of `VECTOR<TYPE>(DIMENSION)`) in type predicate expressions.

The following examples uses a `VECTOR` (constructed using the xref:functions/vector.adoc#functions-vector[`vector()` function]) with `3` dimensions and `INTEGER8` coordinate type.

.Verify a `VECTOR<TYPE>(DIMENSION)` value against the `VECTOR` supertype
[source, cypher]
----
WITH vector([1, 2, 3], 3, INTEGER8) AS vector
RETURN vector IS :: VECTOR AS isVector
----

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
|===
| isVector

| true

1+d|Rows: 1
|===

The same is true for the supertypes `VECTOR<TYPE>` (which encompasses all `VECTOR` values with the same coordinate type regardless of the dimension) and `VECTOR(DIMENSION)` (which encompasses all `VECTOR` values with the same dimension regardless of the coordinate type).

.Verify a `VECTOR<TYPE>(DIMENSION)` value against the `VECTOR<TYPE>` supertype
[source, cypher]
----
WITH vector([1, 2, 3], 3, INTEGER8) AS vector
RETURN vector IS :: VECTOR<INTEGER8> AS isInteger8Vector
----

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
|===
| isInteger8Vector

| true

1+d|Rows: 1
|===

.Verify a `VECTOR<TYPE>(DIMENSION)` value against the `VECTOR(DIMENSION)` supertype
[source, cypher]
----
WITH vector([1, 2, 3], 3, INTEGER8) AS vector
RETURN vector IS :: VECTOR(3) AS isDimension3Vector
----

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
|===
| isDimension3Vector

| true

1+d|Rows: 1
|===

If the coordinate type or dimension in the `VECTOR` does not match what is specified in the type predicate expression, the result will be `false`.

.Verify a `VECTOR<TYPE>(DIMENSION)` value against a `VECTOR` with a different dimension
[source, cypher]
----
WITH vector([1, 2, 3], 3, INTEGER8) AS vector
RETURN vector IS :: VECTOR(5) AS isDimension5Vector
----

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
|===
| isDimension5Vector

| false

1+d|Rows: 1
|===


.Verify a `VECTOR<TYPE>(DIMENSION)` value against a `VECTOR` with a different coordinate type
[source, cypher]
----
WITH vector([1, 2, 3], 3, INTEGER8) AS vector
RETURN vector IS :: VECTOR<INTEGER16> AS isInteger16Vector
----

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
|===
| isInteger16Vector

| false

1+d|Rows: 1
|===

.Verify a `VECTOR<TYPE>(DIMENSION)` value against a `VECTOR` the same coordinate type and dimension
[source, cypher]
----
WITH vector([1, 2, 3], 3, INTEGER8) AS vector
RETURN vector IS :: VECTOR<INTEGER8>(3) AS isVector
----

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
|===
| isVector

| true

1+d|Rows: 1
|===


[[type-predicate-not]]
== Type predicate expressions with NOT

Expand Down Expand Up @@ -205,6 +321,9 @@ RETURN $int16param IS :: INTEGER AS isInteger

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

[NOTE]
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.

[[type-predicate-syntax-variation]]
== Syntactical variations of type predicate expressions

Expand Down
25 changes: 21 additions & 4 deletions modules/ROOT/pages/functions/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ Converts a `LIST<ANY>` of values to a `LIST<BOOLEAN>` values.
If any values are not convertible to `BOOLEAN` they will be null in the `LIST<BOOLEAN>` returned.

1.1+| xref::functions/list.adoc#functions-tofloatlist[`toFloatList()`]
| `toFloatList(input :: LIST<ANY>) :: LIST<FLOAT>`
| `toFloatList(input :: VECTOR \| LIST<ANY>) :: LIST<FLOAT>`
a|
Converts a `LIST<ANY>` to a `LIST<FLOAT>` values.
If any values are not convertible to `FLOAT` they will be null in the `LIST<FLOAT>` returned.

1.1+| xref::functions/list.adoc#functions-tointegerlist[`toIntegerList()`]
| `toIntegerList(input :: LIST<ANY>) :: LIST<INTEGER>`
| `toIntegerList(input :: VECTOR \| LIST<ANY>) :: LIST<INTEGER>`
a|
Converts a `LIST<ANY>` to a `LIST<INTEGER>` values.
If any values are not convertible to `INTEGER` they will be null in the `LIST<INTEGER>` returned.
Expand Down Expand Up @@ -791,12 +791,29 @@ Vector functions allow you to compute the similarity scores of vector pairs.
|===
| Function | Signature | Description

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

1.1+| xref::functions/vector.adoc#functions-similarity-cosine[`vector.similarity.cosine()`]
| `vector.similarity.cosine(a :: LIST<INTEGER \| FLOAT>, b :: LIST<INTEGER \| FLOAT>) :: FLOAT`
| `vector.similarity.cosine(a :: VECTOR \| LIST<INTEGER \| FLOAT>, b :: VECTOR \| LIST<INTEGER \| FLOAT>) :: FLOAT`
| Returns a `FLOAT` representing the similarity between the argument vectors based on their cosine.

1.1+| xref::functions/vector.adoc#functions-similarity-euclidean[`vector.similarity.euclidean()`]
| `vector.similarity.euclidean(a :: LIST<INTEGER \| FLOAT>, b :: LIST<INTEGER \| FLOAT>) :: FLOAT`
| `vector.similarity.euclidean(a :: VECTOR \| LIST<INTEGER \| FLOAT>, b :: VECTOR \| LIST<INTEGER \| FLOAT>) :: FLOAT`
| Returns a `FLOAT` representing the similarity between the argument vectors based on their Euclidean distance.

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

1.1+| xref::functions/vector.adoc#functions-vector_distance[`vector_distance()`]
| `(vector1 :: VECTOR, vector2 :: VECTOR, vectorDistanceMetric :: [EUCLIDEAN, EUCLIDEAN_SQUARED, MANHATTAN, COSINE, DOT, HAMMING]) :: FLOAT`
| Returns a `FLOAT` representing the distance between the two vector values based on the selected `vectorDistanceMetric` algorithm. label:new[Introduced in Neo4j 2025.xx]

1.1+| xref::functions/vector.adoc#functions-vector_norm[`vector_norm()`]
| `vector_norm(vector :: VECTOR, vectorDistanceMetric :: [EUCLIDEAN, MANHATTAN]) :: FLOAT`
| Returns a `FLOAT` representing the distance between the given vector and a vector of the same dimension with all coordinates set to zero, calculated using the specified `vectorDistanceMetric`. label:new[Introduced in Neo4j 2025.xx]

|===

30 changes: 16 additions & 14 deletions modules/ROOT/pages/functions/list.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ The property named `likedColors` and a `LIST<ANY>` comprising all but the first
| Any `BOOLEAN` value in `input` is preserved.
| If the `input` is `null`, `null` will be returned.
| If the `input` is not a `LIST<ANY>`, an error will be returned.
| The conversion for each value in `list` is done according to the xref::functions/scalar.adoc#functions-tobooleanornull[`toBooleanOrNull()` function].
| The conversion for each value in `input` is done according to the xref::functions/scalar.adoc#functions-tobooleanornull[`toBooleanOrNull()` function].

|===

Expand Down Expand Up @@ -470,19 +470,20 @@ toBooleanList(['a string', true, 'false', null, ['A','B']]) as mixedList
.Details
|===
| *Syntax* 3+| `toFloatList(input)`
| *Description* 3+| Converts a `LIST<ANY>` to a `LIST<FLOAT>` values. If any values are not convertible to `FLOAT` they will be null in the `LIST<FLOAT>` returned.
| *Description* 3+| Converts a `LIST<ANY>` or a `VECTOR` to a `LIST<FLOAT>` values. If any values are not convertible to `FLOAT` they will be null in the `LIST<FLOAT>` returned.
.2+| *Arguments* | *Name* | *Type* | *Description*
| `input` | `LIST<ANY>` | A list of values to be converted into a list of floats.
| `input` | `VECTOR` \| `LIST<ANY>` | A list of values or a vector value to be converted into a list of floats.
| *Returns* 3+| `LIST<FLOAT>`
|===

.Considerations
|===

| Any `null` element in `list` is preserved.
| Any `FLOAT` value in `list` is preserved.
| Any `null` element in `input` is preserved.
| Any `FLOAT` value in `input` is preserved.
| If the `input` is `null`, `null` will be returned.
| If the `input` is not a `LIST<ANY>`, an error will be returned.
| If the `input` is not a `VECTOR` or `LIST<ANY>`, an error will be returned.
| `input` accepts `VECTOR` values as of Neo4j 2025.xx
| The conversion for each value in `input` is done according to the xref::functions/scalar.adoc#functions-tofloatornull[`toFloatOrNull()` function].

|===
Expand Down Expand Up @@ -520,9 +521,9 @@ toFloatList(['a string', 2.5, '3.14159', null, ['A','B']]) as mixedList
.Details
|===
| *Syntax* 3+| `toIntegerList(input)`
| *Description* 3+| Converts a `LIST<ANY>` to a `LIST<INTEGER>` values. If any values are not convertible to `INTEGER` they will be null in the `LIST<INTEGER>` returned.
| *Description* 3+| Converts a `LIST<ANY>` or a `VECTOR` to a `LIST<INTEGER>` values. If any values are not convertible to `INTEGER` they will be null in the `LIST<INTEGER>` returned.
.2+| *Arguments* | *Name* | *Type* | *Description*
| `input` | `LIST<ANY>` | A list of values to be converted into a list of integers.
| `input` | `VECTOR` \| `LIST<ANY>` | A list of values or a vector value to be converted into a list of integers.
| *Returns* 3+| `LIST<INTEGER>`
|===

Expand All @@ -532,7 +533,8 @@ toFloatList(['a string', 2.5, '3.14159', null, ['A','B']]) as mixedList
| Any `null` element in `input` is preserved.
| Any `INTEGER` value in `input` is preserved.
| If the `input` is `null`, `null` will be returned.
| If the `input` is not a `LIST<ANY>`, an error will be returned.
| If the `input` is not a `VECTOR` or a `LIST<ANY>`, an error will be returned.
| `input` accepts `VECTOR` values as of Neo4j 2025.xx
| The conversion for each value in `list` is done according to the xref::functions/scalar.adoc#functions-tointegerornull[`toIntegerOrNull()` function].

|===
Expand Down Expand Up @@ -579,11 +581,11 @@ toIntegerList(['a string', 2, '5', null, ['A','B']]) as mixedList
.Considerations
|===

| Any `null` element in `list` is preserved.
| Any `STRING` value in `list` is preserved.
| If the `list` is `null`, `null` will be returned.
| If the `list` is not a `LIST<ANY>`, an error will be returned.
| The conversion for each value in `list` is done according to the xref::functions/string.adoc#functions-tostringornull[`toStringOrNull()` function].
| Any `null` element in `input` is preserved.
| Any `STRING` value in `input` is preserved.
| If the `input` is `null`, `null` will be returned.
| If the `input` is not a `LIST<ANY>`, an error will be returned.
| The conversion for each value in `input` is done according to the xref::functions/string.adoc#functions-tostringornull[`toStringOrNull()` function].

|===

Expand Down
Loading