Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
44 changes: 44 additions & 0 deletions modules/ROOT/pages/constraints/managing-constraints.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
:description: Information about creating, listing, and dropping Neo4j's constraints.
include::https://raw.githubusercontent.com/neo4j-graphacademy/courses/main/asciidoc/courses/cypher-indexes-constraints/ad.adoc[]
:page-aliases: constraints/examples.adoc
Expand Down Expand Up @@ -344,6 +344,41 @@

======

.Create `VECTOR` property type constraints label:new[Introduced in Neo4j 2025.xx]
======

It is necessary to specify both the dimension and the coordinate type of any constrained `VECTOR` properties.
The dimension must be greater than `0` and less or equal to `4096`.
For more information, see xref:values-and-types/vector.adoc[Values and types -> Vectors].

.Create a constraint requiring `embedding` properties on `Movie` nodes to be of type `VECTOR<INT32>(42)`
[source, cypher]
----
CREATE CONSTRAINT node_vector_constraint
FOR (n:Movie) REQUIRE n.embedding IS :: VECTOR<INT32>(42)
----

.Result
[source, queryresult]
----
Added 1 constraint.
----

.Create a constraint requiring `embedding` properties on `CONTAINS` relationships to be of type `VECTOR<FLOAT32>(1536)`
[source, cypher]
----
CREATE CONSTRAINT rel_vector_constraint
FOR ()-[r:CONTAINS]->() REQUIRE r.embedding IS :: VECTOR<FLOAT32>(1536)
----

.Result
[source, queryresult]
----
Added 1 constraint.
----

======

[[create-property-type-constraint-union-type]]
==== Create property type constraints with a union type

Expand Down Expand Up @@ -401,6 +436,7 @@
* `ZONED DATETIME`
* `DURATION`
* `POINT`
* `VECTOR<TYPE>(DIMENSION)` label:new[Introduced in Neo4j 2025.xx]
* `LIST<BOOLEAN NOT NULL>`
* `LIST<STRING NOT NULL>`
* `LIST<INTEGER NOT NULL>`
Expand All @@ -414,6 +450,10 @@
* `LIST<POINT NOT NULL>`
* Any closed dynamic union of the above types, e.g. `INTEGER | FLOAT | STRING`.

[NOTE]
A property type constraint cannot be created for `LIST<VECTOR NOT NULL>`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A property type constraint cannot be created for `LIST<VECTOR NOT NULL>`.
A property type constraint cannot be created for `LIST<VECTOR<TYPE>(DIMENSION) NOT NULL>`.

maybe? since the base one have them it feels odd not to have them in the list one 🤷

This is because it is not possible to store lists of xref:values-and-types/vector.adoc[`VECTOR`] values.

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

[[fail-to-create-property-type-constraint-invalid-type]]
Expand Down Expand Up @@ -697,6 +737,7 @@
This includes:

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

However, some constraint types are allowed on the same label/relationship type and property combination.
Expand Down Expand Up @@ -1653,6 +1694,9 @@
== DROP CONSTRAINT

Constraints are dropped using the `DROP CONSTRAINT` command.
It is possible to drop a constraint that was created in a later Cypher version than the one currently in use.
For example, although `VECTOR` property type constraints were added in Cypher 25, such constraints can still be dropped using Cypher 5.

For the full command syntax to drop constraints, see xref:constraints/syntax.adoc#drop-constraint[Syntax -> DROP CONSTRAINT].

[NOTE]
Expand Down
7 changes: 7 additions & 0 deletions modules/ROOT/pages/constraints/syntax.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
:description: Syntax for how to manage constraints used for ensuring data integrity.

[[constraints-syntax]]
Expand Down Expand Up @@ -122,6 +122,7 @@
* `ZONED DATETIME`
* `DURATION`
* `POINT`
* `VECTOR<TYPE>(DIMENSION)` label:new[Introduced in Neo4j 2025.xx]
* `LIST<BOOLEAN NOT NULL>`
* `LIST<STRING NOT NULL>`
* `LIST<INTEGER NOT NULL>`
Expand All @@ -135,6 +136,12 @@
* `LIST<POINT NOT NULL>`
* Any closed dynamic union of the above types, e.g. `INTEGER | FLOAT | STRING`.

[NOTE]
A property type constraint cannot be created for `LIST<VECTOR NOT NULL>`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A property type constraint cannot be created for `LIST<VECTOR NOT NULL>`.
A property type constraint cannot be created for `LIST<VECTOR<TYPE>(DIMENSION) NOT NULL>`.

as in the other file

This is because it is not possible to store lists of `VECTOR` values.
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`.
For more information, see xref:values-and-types/vector.adoc[Values and types -> Vectors].

Allowed syntax variations of these types are listed in xref::values-and-types/property-structural-constructed.adoc#types-synonyms[Types and their synonyms].

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].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,36 @@ Cypher 25 was introduced in Neo4j 2025.06 and can only be used on Neo4j 2025.06+
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.
For more information, see xref:queries/select-version.adoc[].

[[cypher-deprecations-additions-removals-2025.xx]]
== Neo4j 2025.xx

=== New in Cypher 25

[cols="2", options="header"]
|===
| Feature
| Details

a|
label:functionality[]
label:new[]

[source, cypher, role="noheader"]
----
CREATE CONSTRAINT node_vector_constraint
FOR (n:Movie) REQUIRE n.embedding IS :: VECTOR<INT32>(42)
----

[source, cypher, role="noheader"]
----
CREATE CONSTRAINT rel_vector_constraint
FOR ()-[r:CONTAINS]->() REQUIRE r.embedding IS :: VECTOR<FLOAT32>(1536)
----

a| Introduced `VECTOR` property type constraints.
For more information, see xref:constraints/managing-constraints.adoc#create-property-type-constraints[Create property type constraints].
|===

[[cypher-deprecations-additions-removals-2025.06]]
== Neo4j 2025.06

Expand Down
Loading