Skip to content

Commit 23832f8

Browse files
initial
1 parent a712679 commit 23832f8

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

modules/ROOT/pages/constraints/managing-constraints.adoc

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,41 @@ Added 1 constraint.
344344
345345
======
346346

347+
.Create `VECTOR` property type constraints
348+
======
349+
350+
It is necessary to specify both the dimension and the coordinate type of any constrained `VECTOR` properties.
351+
The dimension must be greater than `0` and less or equal to `4096`.
352+
For more information, see xref:values-and-types/vectors.adoc[Values and types -> Vectors].
353+
354+
.Create a constraint requiring `embedding` properties on `Movie` nodes to be of type `VECTOR<INT32>(42)`
355+
[source, cypher]
356+
----
357+
CREATE CONSTRAINT node_vector_constraint
358+
FOR (n:Movie) REQUIRE n.embedding IS :: VECTOR<INT32>(42)
359+
----
360+
361+
.Result
362+
[source, queryresult]
363+
----
364+
Added 1 constraint.
365+
----
366+
367+
.Create a constraint requiring `embedding` properties on `CONTAINS` relationships to be of type `VECTOR<FLOAT32>(1536)`
368+
[source, cypher]
369+
----
370+
CREATE CONSTRAINT rel_vector_constraint
371+
FOR ()-[r:CONTAINS]->() REQUIRE r.embedding IS :: VECTOR<FLOAT32>(1536)
372+
----
373+
374+
.Result
375+
[source, queryresult]
376+
----
377+
Added 1 constraint.
378+
----
379+
380+
======
381+
347382
[[create-property-type-constraint-union-type]]
348383
==== Create property type constraints with a union type
349384

@@ -401,6 +436,7 @@ The allowed property types for property type constraints are:
401436
* `ZONED DATETIME`
402437
* `DURATION`
403438
* `POINT`
439+
* `VECTOR<TYPE>(DIMENSION)` label:new[Introduced in Neo4j 2025.xx]
404440
* `LIST<BOOLEAN NOT NULL>`
405441
* `LIST<STRING NOT NULL>`
406442
* `LIST<INTEGER NOT NULL>`
@@ -414,6 +450,10 @@ The allowed property types for property type constraints are:
414450
* `LIST<POINT NOT NULL>`
415451
* Any closed dynamic union of the above types, e.g. `INTEGER | FLOAT | STRING`.
416452

453+
[NOTE]
454+
A property type constraint cannot be created for `LIST<VECTOR NOT NULL>`.
455+
This is because it is not possible to store lists of xref:values-and-types/vectors.adoc[`VECTOR`] values.
456+
417457
For a complete reference describing all types available in Cypher, see the section on xref::values-and-types/property-structural-constructed.adoc#types-synonyms[types and their synonyms].
418458

419459
[[fail-to-create-property-type-constraint-invalid-type]]
@@ -697,6 +737,7 @@ Additionally, some constraints cannot coexist and attempting to create them toge
697737
This includes:
698738

699739
* Property type constraints on the same label/relationship type and property but with different property types.
740+
This includes `VECTOR` types with differing dimensions or coordinate types.
700741
* Property uniqueness and key constraints on the same label/relationship type and property combination.
701742

702743
However, some constraint types are allowed on the same label/relationship type and property combination.
@@ -1653,6 +1694,9 @@ label:default-output[]
16531694
== DROP CONSTRAINT
16541695

16551696
Constraints are dropped using the `DROP CONSTRAINT` command.
1697+
It is possible to drop a constraint that was created in a later Cypher version than the one currently in use.
1698+
For example, although `VECTOR` property type constraints were added in Cypher 25, such constraints can still be dropped using Cypher 5.
1699+
16561700
For the full command syntax to drop constraints, see xref:constraints/syntax.adoc#drop-constraint[Syntax -> DROP CONSTRAINT].
16571701

16581702
[NOTE]

modules/ROOT/pages/constraints/syntax.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ Where `<TYPE>` is one of the following property types:
122122
* `ZONED DATETIME`
123123
* `DURATION`
124124
* `POINT`
125+
* `VECTOR<TYPE>(DIMENSION)` label:new[Introduced in Neo4j 2025.xx]
125126
* `LIST<BOOLEAN NOT NULL>`
126127
* `LIST<STRING NOT NULL>`
127128
* `LIST<INTEGER NOT NULL>`
@@ -135,6 +136,12 @@ Where `<TYPE>` is one of the following property types:
135136
* `LIST<POINT NOT NULL>`
136137
* Any closed dynamic union of the above types, e.g. `INTEGER | FLOAT | STRING`.
137138

139+
[NOTE]
140+
A property type constraint cannot be created for `LIST<VECTOR NOT NULL>`.
141+
This is because it is not possible to store lists of `VECTOR` values.
142+
Additionally, `VECTOR` property type constraints must be created with a specific dimension and coordinate value, where the dimension must be greater than `0` and less or equal to `4096`.
143+
For more information, see xref:values-and-types/vectors.adoc[Values and types -> Vectors].
144+
138145
Allowed syntax variations of these types are listed in xref::values-and-types/property-structural-constructed.adoc#types-synonyms[Types and their synonyms].
139146

140147
For examples on how to create property type constraints, see xref:constraints/managing-constraints.adoc#create-property-type-constraints[Create, show, and drop constraints -> Create property type constraints].

modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,36 @@ Cypher 25 was introduced in Neo4j 2025.06 and can only be used on Neo4j 2025.06+
2222
Features removed in Cypher 25 are still available on Neo4j 2025.06+ databases either by prepending a query with `CYPHER 5` or by having Cypher 5 as the default language for the database.
2323
For more information, see xref:queries/select-version.adoc[].
2424

25+
[[cypher-deprecations-additions-removals-2025.xx]]
26+
== Neo4j 2025.xx
27+
28+
=== New in Cypher 25
29+
30+
[cols="2", options="header"]
31+
|===
32+
| Feature
33+
| Details
34+
35+
a|
36+
label:functionality[]
37+
label:new[]
38+
39+
[source, cypher, role="noheader"]
40+
----
41+
CREATE CONSTRAINT node_vector_constraint
42+
FOR (n:Movie) REQUIRE n.embedding IS :: VECTOR<INT32>(42)
43+
----
44+
45+
[source, cypher, role="noheader"]
46+
----
47+
CREATE CONSTRAINT rel_vector_constraint
48+
FOR ()-[r:CONTAINS]->() REQUIRE r.embedding IS :: VECTOR<FLOAT32>(1536)
49+
----
50+
51+
a| Introduced `VECTOR` property type constraints.
52+
For more information, see xref:constraints/managing-constraints.adoc#create-property-type-constraints[Create property type constraints].
53+
|===
54+
2555
[[cypher-deprecations-additions-removals-2025.06]]
2656
== Neo4j 2025.06
2757

0 commit comments

Comments
 (0)