diff --git a/modules/ROOT/pages/constraints/managing-constraints.adoc b/modules/ROOT/pages/constraints/managing-constraints.adoc index 2975482a9..3b63b8eb7 100644 --- a/modules/ROOT/pages/constraints/managing-constraints.adoc +++ b/modules/ROOT/pages/constraints/managing-constraints.adoc @@ -344,6 +344,41 @@ Added 1 constraint. ====== +.Create `VECTOR` property type constraints label:cypher[Cypher 25 only] label:new[Introduced in Neo4j 2025.10] +====== + +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(42)` +[source, cypher] +---- +CREATE CONSTRAINT node_vector_constraint +FOR (n:Movie) REQUIRE n.embedding IS :: VECTOR(42) +---- + +.Result +[source, queryresult] +---- +Added 1 constraint. +---- + +.Create a constraint requiring `embedding` properties on `CONTAINS` relationships to be of type `VECTOR(1536)` +[source, cypher] +---- +CREATE CONSTRAINT rel_vector_constraint +FOR ()-[r:CONTAINS]->() REQUIRE r.embedding IS :: VECTOR(1536) +---- + +.Result +[source, queryresult] +---- +Added 1 constraint. +---- + +====== + [[create-property-type-constraint-union-type]] ==== Create property type constraints with a union type @@ -401,6 +436,7 @@ The allowed property types for property type constraints are: * `ZONED DATETIME` * `DURATION` * `POINT` +* `VECTOR(DIMENSION)` label:cypher[Cypher 25 only] label:new[Introduced in Neo4j 2025.10] * `LIST` * `LIST` * `LIST` @@ -414,6 +450,9 @@ The allowed property types for property type constraints are: * `LIST` * Any closed dynamic union of the above types, e.g. `INTEGER | FLOAT | STRING`. +[NOTE] +Because storing lists of xref:values-and-types/vector.adoc[`VECTOR`] values is not supported, property type constraints cannot be created for `LIST(DIMENSION) NOT NULL>`. + 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]] @@ -697,6 +736,7 @@ Additionally, some constraints cannot coexist and attempting to create them toge This includes: * Property type constraints on the same label/relationship type and property but with different property types. +This includes `VECTOR` types with different 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. @@ -1055,7 +1095,7 @@ A constraint cannot be created until the index has been dropped. | *Property uniqueness constraint* | ^| ❌ -| +| | *Property existence constraint* ^| ❌ @@ -1222,7 +1262,7 @@ Node(9) with label `Movie` required the property `title` to be of type `STRING`, | *Property uniqueness constraint* | ^| ❌ -| +| | *Property existence constraint* ^| ❌ @@ -1324,7 +1364,7 @@ RETURN wrote | Query | Node property uniqueness constraint -a| +a| [source] ---- MATCH (n1:Label), (n2:Label) @@ -1333,7 +1373,7 @@ RETURN n1, n2 ---- | Relationship property uniqueness constraint -a| +a| [source] ---- MATCH ()-[r1:REL_TYPE]->(), ()-[r2:REL_TYPE]->() @@ -1342,7 +1382,7 @@ RETURN r1, r2 ---- | Node property existence constraint -a| +a| [source] ---- MATCH (n:Label) @@ -1351,7 +1391,7 @@ RETURN n ---- | Relationship property existence constraint -a| +a| [source] ---- MATCH ()-[r:REL_TYPE]->() @@ -1360,7 +1400,7 @@ RETURN r ---- | Node property type constraint -a| +a| [source] ---- MATCH (n:Label) @@ -1369,7 +1409,7 @@ RETURN n ---- | Relationship property type constraint -a| +a| [source] ---- MATCH ()-[r:REL_TYPE]->() @@ -1378,7 +1418,7 @@ RETURN r ---- | Node key constraint -a| +a| [source] ---- MATCH (n1:Label), (n2:Label) @@ -1392,7 +1432,7 @@ RETURN n AS node, 'non-existing' AS reason ---- | Relationship key constraint -a| +a| [source] ---- MATCH ()-[r1:REL_TYPE]->(), ()-[r2:REL_TYPE]->() @@ -1432,26 +1472,28 @@ SHOW CONSTRAINTS .Result [source, queryresult] ---- -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| id | name | type | entityType | labelsOrTypes | properties | ownedIndex | propertyType | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 21 | "actor_fullname" | "NODE_KEY" | "NODE" | ["Actor"] | ["firstname", "surname"] | "actor_fullname" | NULL | -| 10 | "author_name" | "NODE_PROPERTY_EXISTENCE" | "NODE" | ["Author"] | ["name"] | NULL | NULL | -| 3 | "book_isbn" | "NODE_PROPERTY_UNIQUENESS" | "NODE" | ["Book"] | ["isbn"] | "book_isbn" | NULL | -| 7 | "book_title_year" | "NODE_PROPERTY_UNIQUENESS" | "NODE" | ["Book"] | ["title", "publicationYear"] | "book_title_year" | NULL | -| 17 | "director_imdbId" | "NODE_KEY" | "NODE" | ["Director"] | ["imdbId"] | "director_imdbId" | NULL | -| 23 | "knows_since_how" | "RELATIONSHIP_KEY" | "RELATIONSHIP" | ["KNOWS"] | ["since", "how"] | "knows_since_how" | NULL | -| 14 | "movie_tagline" | "NODE_PROPERTY_TYPE" | "NODE" | ["Movie"] | ["tagline"] | NULL | "STRING | LIST" | -| 12 | "movie_title" | "NODE_PROPERTY_TYPE" | "NODE" | ["Movie"] | ["title"] | NULL | "STRING" | -| 25 | "node_uniqueness_param" | "NODE_PROPERTY_UNIQUENESS" | "NODE" | ["Book"] | ["prop1"] | "node_uniqueness_param" | NULL | -| 19 | "ownershipId" | "RELATIONSHIP_KEY" | "RELATIONSHIP" | ["OWNS"] | ["ownershipId"] | "ownershipId" | NULL | -| 13 | "part_of" | "RELATIONSHIP_PROPERTY_TYPE" | "RELATIONSHIP" | ["PART_OF"] | ["order"] | NULL | "INTEGER" | -| 15 | "part_of_tags" | "RELATIONSHIP_PROPERTY_TYPE" | "RELATIONSHIP" | ["PART_OF"] | ["tags"] | NULL | "STRING | LIST" | -| 9 | "prequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "RELATIONSHIP" | ["PREQUEL_OF"] | ["order", "author"] | "prequels" | NULL | -| 26 | "rel_exist_param" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "RELATIONSHIP" | ["WROTE"] | ["published"] | NULL | NULL | -| 5 | "sequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "RELATIONSHIP" | ["SEQUEL_OF"] | ["order"] | "sequels" | NULL | -| 11 | "wrote_year" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "RELATIONSHIP" | ["WROTE"] | ["year"] | NULL | NULL | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| id | name | type | entityType | labelsOrTypes | properties | ownedIndex | propertyType | ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 23 | "actor_fullname" | "NODE_KEY" | "NODE" | ["Actor"] | ["firstname", "surname"] | "actor_fullname" | NULL | +| 12 | "author_name" | "NODE_PROPERTY_EXISTENCE" | "NODE" | ["Author"] | ["name"] | NULL | NULL | +| 5 | "book_isbn" | "NODE_PROPERTY_UNIQUENESS" | "NODE" | ["Book"] | ["isbn"] | "book_isbn" | NULL | +| 9 | "book_title_year" | "NODE_PROPERTY_UNIQUENESS" | "NODE" | ["Book"] | ["title", "publicationYear"] | "book_title_year" | NULL | +| 19 | "director_imdbId" | "NODE_KEY" | "NODE" | ["Director"] | ["imdbId"] | "director_imdbId" | NULL | +| 25 | "knows_since_how" | "RELATIONSHIP_KEY" | "RELATIONSHIP" | ["KNOWS"] | ["since", "how"] | "knows_since_how" | NULL | +| 16 | "movie_tagline" | "NODE_PROPERTY_TYPE" | "NODE" | ["Movie"] | ["tagline"] | NULL | "STRING | LIST" | +| 14 | "movie_title" | "NODE_PROPERTY_TYPE" | "NODE" | ["Movie"] | ["title"] | NULL | "STRING" | +| 27 | "node_uniqueness_param" | "NODE_PROPERTY_UNIQUENESS" | "NODE" | ["Book"] | ["prop1"] | "node_uniqueness_param" | NULL | +| 2 | "node_vector_constraint" | "NODE_PROPERTY_TYPE" | "NODE" | ["Movie"] | ["embedding"] | NULL | "VECTOR(42)" | +| 21 | "ownershipId" | "RELATIONSHIP_KEY" | "RELATIONSHIP" | ["OWNS"] | ["ownershipId"] | "ownershipId" | NULL | +| 15 | "part_of" | "RELATIONSHIP_PROPERTY_TYPE" | "RELATIONSHIP" | ["PART_OF"] | ["order"] | NULL | "INTEGER" | +| 17 | "part_of_tags" | "RELATIONSHIP_PROPERTY_TYPE" | "RELATIONSHIP" | ["PART_OF"] | ["tags"] | NULL | "STRING | LIST" | +| 11 | "prequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "RELATIONSHIP" | ["PREQUEL_OF"] | ["order", "author"] | "prequels" | NULL | +| 28 | "rel_exist_param" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "RELATIONSHIP" | ["WROTE"] | ["published"] | NULL | NULL | +| 3 | "rel_vector_constraint" | "RELATIONSHIP_PROPERTY_TYPE" | "RELATIONSHIP" | ["CONTAINS"] | ["embedding"] | NULL | "VECTOR(1536)" | +| 7 | "sequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "RELATIONSHIP" | ["SEQUEL_OF"] | ["order"] | "sequels" | NULL | +| 13 | "wrote_year" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "RELATIONSHIP" | ["WROTE"] | ["year"] | NULL | NULL | ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ---- ====== @@ -1470,26 +1512,28 @@ SHOW CONSTRAINTS YIELD * .Result [source, queryresult] ---- -+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| id | name | type | entityType | labelsOrTypes | properties | ownedIndex | propertyType | options | createStatement | -+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 21 | "actor_fullname" | "NODE_KEY" | "NODE" | ["Actor"] | ["firstname", "surname"] | "actor_fullname" | NULL | {indexConfig: {}, indexProvider: "range-1.0"} | "CREATE CONSTRAINT `actor_fullname` FOR (n:`Actor`) REQUIRE (n.`firstname`, n.`surname`) IS KEY" | -| 10 | "author_name" | "NODE_PROPERTY_EXISTENCE" | "NODE" | ["Author"] | ["name"] | NULL | NULL | NULL | "CREATE CONSTRAINT `author_name` FOR (n:`Author`) REQUIRE (n.`name`) IS NOT NULL" | -| 3 | "book_isbn" | "NODE_PROPERTY_UNIQUENESS" | "NODE" | ["Book"] | ["isbn"] | "book_isbn" | NULL | {indexConfig: {}, indexProvider: "range-1.0"} | "CREATE CONSTRAINT `book_isbn` FOR (n:`Book`) REQUIRE (n.`isbn`) IS UNIQUE" | -| 7 | "book_title_year" | "NODE_PROPERTY_UNIQUENESS" | "NODE" | ["Book"] | ["title", "publicationYear"] | "book_title_year" | NULL | {indexConfig: {}, indexProvider: "range-1.0"} | "CREATE CONSTRAINT `book_title_year` FOR (n:`Book`) REQUIRE (n.`title`, n.`publicationYear`) IS UNIQUE" | -| 17 | "director_imdbId" | "NODE_KEY" | "NODE" | ["Director"] | ["imdbId"] | "director_imdbId" | NULL | {indexConfig: {}, indexProvider: "range-1.0"} | "CREATE CONSTRAINT `director_imdbId` FOR (n:`Director`) REQUIRE (n.`imdbId`) IS KEY" | -| 23 | "knows_since_how" | "RELATIONSHIP_KEY" | "RELATIONSHIP" | ["KNOWS"] | ["since", "how"] | "knows_since_how" | NULL | {indexConfig: {}, indexProvider: "range-1.0"} | "CREATE CONSTRAINT `knows_since_how` FOR ()-[r:`KNOWS`]-() REQUIRE (r.`since`, r.`how`) IS KEY" | -| 14 | "movie_tagline" | "NODE_PROPERTY_TYPE" | "NODE" | ["Movie"] | ["tagline"] | NULL | "STRING | LIST" | NULL | "CREATE CONSTRAINT `movie_tagline` FOR (n:`Movie`) REQUIRE (n.`tagline`) IS :: STRING | LIST" | -| 12 | "movie_title" | "NODE_PROPERTY_TYPE" | "NODE" | ["Movie"] | ["title"] | NULL | "STRING" | NULL | "CREATE CONSTRAINT `movie_title` FOR (n:`Movie`) REQUIRE (n.`title`) IS :: STRING" | -| 25 | "node_uniqueness_param" | "NODE_PROPERTY_UNIQUENESS" | "NODE" | ["Book"] | ["prop1"] | "node_uniqueness_param" | NULL | {indexConfig: {}, indexProvider: "range-1.0"} | "CREATE CONSTRAINT `node_uniqueness_param` FOR (n:`Book`) REQUIRE (n.`prop1`) IS UNIQUE" | -| 19 | "ownershipId" | "RELATIONSHIP_KEY" | "RELATIONSHIP" | ["OWNS"] | ["ownershipId"] | "ownershipId" | NULL | {indexConfig: {}, indexProvider: "range-1.0"} | "CREATE CONSTRAINT `ownershipId` FOR ()-[r:`OWNS`]-() REQUIRE (r.`ownershipId`) IS KEY" | -| 13 | "part_of" | "RELATIONSHIP_PROPERTY_TYPE" | "RELATIONSHIP" | ["PART_OF"] | ["order"] | NULL | "INTEGER" | NULL | "CREATE CONSTRAINT `part_of` FOR ()-[r:`PART_OF`]-() REQUIRE (r.`order`) IS :: INTEGER" | -| 15 | "part_of_tags" | "RELATIONSHIP_PROPERTY_TYPE" | "RELATIONSHIP" | ["PART_OF"] | ["tags"] | NULL | "STRING | LIST" | NULL | "CREATE CONSTRAINT `part_of_tags` FOR ()-[r:`PART_OF`]-() REQUIRE (r.`tags`) IS :: STRING | LIST" | -| 9 | "prequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "RELATIONSHIP" | ["PREQUEL_OF"] | ["order", "author"] | "prequels" | NULL | {indexConfig: {}, indexProvider: "range-1.0"} | "CREATE CONSTRAINT `prequels` FOR ()-[r:`PREQUEL_OF`]-() REQUIRE (r.`order`, r.`author`) IS UNIQUE" | -| 26 | "rel_exist_param" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "RELATIONSHIP" | ["WROTE"] | ["published"] | NULL | NULL | NULL | "CREATE CONSTRAINT `rel_exist_param` FOR ()-[r:`WROTE`]-() REQUIRE (r.`published`) IS NOT NULL" | -| 5 | "sequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "RELATIONSHIP" | ["SEQUEL_OF"] | ["order"] | "sequels" | NULL | {indexConfig: {}, indexProvider: "range-1.0"} | "CREATE CONSTRAINT `sequels` FOR ()-[r:`SEQUEL_OF`]-() REQUIRE (r.`order`) IS UNIQUE" | -| 11 | "wrote_year" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "RELATIONSHIP" | ["WROTE"] | ["year"] | NULL | NULL | NULL | "CREATE CONSTRAINT `wrote_year` FOR ()-[r:`WROTE`]-() REQUIRE (r.`year`) IS NOT NULL" | -+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| id | name | type | entityType | labelsOrTypes | properties | ownedIndex | propertyType | options | createStatement | ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 23 | "actor_fullname" | "NODE_KEY" | "NODE" | ["Actor"] | ["firstname", "surname"] | "actor_fullname" | NULL | {indexConfig: {}} | "CREATE CONSTRAINT `actor_fullname` FOR (n:`Actor`) REQUIRE (n.`firstname`, n.`surname`) IS KEY" | +| 12 | "author_name" | "NODE_PROPERTY_EXISTENCE" | "NODE" | ["Author"] | ["name"] | NULL | NULL | NULL | "CREATE CONSTRAINT `author_name` FOR (n:`Author`) REQUIRE (n.`name`) IS NOT NULL" | +| 5 | "book_isbn" | "NODE_PROPERTY_UNIQUENESS" | "NODE" | ["Book"] | ["isbn"] | "book_isbn" | NULL | {indexConfig: {}} | "CREATE CONSTRAINT `book_isbn` FOR (n:`Book`) REQUIRE (n.`isbn`) IS UNIQUE" | +| 9 | "book_title_year" | "NODE_PROPERTY_UNIQUENESS" | "NODE" | ["Book"] | ["title", "publicationYear"] | "book_title_year" | NULL | {indexConfig: {}} | "CREATE CONSTRAINT `book_title_year` FOR (n:`Book`) REQUIRE (n.`title`, n.`publicationYear`) IS UNIQUE" | +| 19 | "director_imdbId" | "NODE_KEY" | "NODE" | ["Director"] | ["imdbId"] | "director_imdbId" | NULL | {indexConfig: {}} | "CREATE CONSTRAINT `director_imdbId` FOR (n:`Director`) REQUIRE (n.`imdbId`) IS KEY" | +| 25 | "knows_since_how" | "RELATIONSHIP_KEY" | "RELATIONSHIP" | ["KNOWS"] | ["since", "how"] | "knows_since_how" | NULL | {indexConfig: {}} | "CREATE CONSTRAINT `knows_since_how` FOR ()-[r:`KNOWS`]-() REQUIRE (r.`since`, r.`how`) IS KEY" | +| 16 | "movie_tagline" | "NODE_PROPERTY_TYPE" | "NODE" | ["Movie"] | ["tagline"] | NULL | "STRING | LIST" | NULL | "CREATE CONSTRAINT `movie_tagline` FOR (n:`Movie`) REQUIRE (n.`tagline`) IS :: STRING | LIST" | +| 14 | "movie_title" | "NODE_PROPERTY_TYPE" | "NODE" | ["Movie"] | ["title"] | NULL | "STRING" | NULL | "CREATE CONSTRAINT `movie_title` FOR (n:`Movie`) REQUIRE (n.`title`) IS :: STRING" | +| 27 | "node_uniqueness_param" | "NODE_PROPERTY_UNIQUENESS" | "NODE" | ["Book"] | ["prop1"] | "node_uniqueness_param" | NULL | {indexConfig: {}} | "CREATE CONSTRAINT `node_uniqueness_param` FOR (n:`Book`) REQUIRE (n.`prop1`) IS UNIQUE" | +| 2 | "node_vector_constraint" | "NODE_PROPERTY_TYPE" | "NODE" | ["Movie"] | ["embedding"] | NULL | "VECTOR(42)" | NULL | "CREATE CONSTRAINT `node_vector_constraint` FOR (n:`Movie`) REQUIRE (n.`embedding`) IS :: VECTOR(42)" | +| 21 | "ownershipId" | "RELATIONSHIP_KEY" | "RELATIONSHIP" | ["OWNS"] | ["ownershipId"] | "ownershipId" | NULL | {indexConfig: {}} | "CREATE CONSTRAINT `ownershipId` FOR ()-[r:`OWNS`]-() REQUIRE (r.`ownershipId`) IS KEY" | +| 15 | "part_of" | "RELATIONSHIP_PROPERTY_TYPE" | "RELATIONSHIP" | ["PART_OF"] | ["order"] | NULL | "INTEGER" | NULL | "CREATE CONSTRAINT `part_of` FOR ()-[r:`PART_OF`]-() REQUIRE (r.`order`) IS :: INTEGER" | +| 17 | "part_of_tags" | "RELATIONSHIP_PROPERTY_TYPE" | "RELATIONSHIP" | ["PART_OF"] | ["tags"] | NULL | "STRING | LIST" | NULL | "CREATE CONSTRAINT `part_of_tags` FOR ()-[r:`PART_OF`]-() REQUIRE (r.`tags`) IS :: STRING | LIST" | +| 11 | "prequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "RELATIONSHIP" | ["PREQUEL_OF"] | ["order", "author"] | "prequels" | NULL | {indexConfig: {}} | "CREATE CONSTRAINT `prequels` FOR ()-[r:`PREQUEL_OF`]-() REQUIRE (r.`order`, r.`author`) IS UNIQUE" | +| 28 | "rel_exist_param" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "RELATIONSHIP" | ["WROTE"] | ["published"] | NULL | NULL | NULL | "CREATE CONSTRAINT `rel_exist_param` FOR ()-[r:`WROTE`]-() REQUIRE (r.`published`) IS NOT NULL" | +| 3 | "rel_vector_constraint" | "RELATIONSHIP_PROPERTY_TYPE" | "RELATIONSHIP" | ["CONTAINS"] | ["embedding"] | NULL | "VECTOR(1536)" | NULL | "CREATE CONSTRAINT `rel_vector_constraint` FOR ()-[r:`CONTAINS`]-() REQUIRE (r.`embedding`) IS :: VECTOR(1536)" | +| 7 | "sequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "RELATIONSHIP" | ["SEQUEL_OF"] | ["order"] | "sequels" | NULL | {indexConfig: {}} | "CREATE CONSTRAINT `sequels` FOR ()-[r:`SEQUEL_OF`]-() REQUIRE (r.`order`) IS UNIQUE" | +| 13 | "wrote_year" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "RELATIONSHIP" | ["WROTE"] | ["year"] | NULL | NULL | NULL | "CREATE CONSTRAINT `wrote_year` FOR ()-[r:`WROTE`]-() REQUIRE (r.`year`) IS NOT NULL" | ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ---- ====== @@ -1539,18 +1583,19 @@ WHERE entityType = 'RELATIONSHIP' .Result [source, queryresult] ---- -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| id | name | type | entityType | labelsOrTypes | properties | ownedIndex | propertyType | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 23 | "knows_since_how" | "RELATIONSHIP_KEY" | "RELATIONSHIP" | ["KNOWS"] | ["since", "how"] | "knows_since_how" | NULL | -| 19 | "ownershipId" | "RELATIONSHIP_KEY" | "RELATIONSHIP" | ["OWNS"] | ["ownershipId"] | "ownershipId" | NULL | -| 13 | "part_of" | "RELATIONSHIP_PROPERTY_TYPE" | "RELATIONSHIP" | ["PART_OF"] | ["order"] | NULL | "INTEGER" | -| 15 | "part_of_tags" | "RELATIONSHIP_PROPERTY_TYPE" | "RELATIONSHIP" | ["PART_OF"] | ["tags"] | NULL | "STRING | LIST" | -| 9 | "prequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "RELATIONSHIP" | ["PREQUEL_OF"] | ["order", "author"] | "prequels" | NULL | -| 26 | "rel_exist_param" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "RELATIONSHIP" | ["WROTE"] | ["published"] | NULL | NULL | -| 5 | "sequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "RELATIONSHIP" | ["SEQUEL_OF"] | ["order"] | "sequels" | NULL | -| 11 | "wrote_year" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "RELATIONSHIP" | ["WROTE"] | ["year"] | NULL | NULL | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| id | name | type | entityType | labelsOrTypes | properties | ownedIndex | propertyType | ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 25 | "knows_since_how" | "RELATIONSHIP_KEY" | "RELATIONSHIP" | ["KNOWS"] | ["since", "how"] | "knows_since_how" | NULL | +| 21 | "ownershipId" | "RELATIONSHIP_KEY" | "RELATIONSHIP" | ["OWNS"] | ["ownershipId"] | "ownershipId" | NULL | +| 15 | "part_of" | "RELATIONSHIP_PROPERTY_TYPE" | "RELATIONSHIP" | ["PART_OF"] | ["order"] | NULL | "INTEGER" | +| 17 | "part_of_tags" | "RELATIONSHIP_PROPERTY_TYPE" | "RELATIONSHIP" | ["PART_OF"] | ["tags"] | NULL | "STRING | LIST" | +| 11 | "prequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "RELATIONSHIP" | ["PREQUEL_OF"] | ["order", "author"] | "prequels" | NULL | +| 28 | "rel_exist_param" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "RELATIONSHIP" | ["WROTE"] | ["published"] | NULL | NULL | +| 3 | "rel_vector_constraint" | "RELATIONSHIP_PROPERTY_TYPE" | "RELATIONSHIP" | ["CONTAINS"] | ["embedding"] | NULL | "VECTOR(1536)" | +| 7 | "sequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "RELATIONSHIP" | ["SEQUEL_OF"] | ["order"] | "sequels" | NULL | +| 13 | "wrote_year" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "RELATIONSHIP" | ["WROTE"] | ["year"] | NULL | NULL | ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ---- ====== @@ -1571,26 +1616,28 @@ YIELD name, type, createStatement .Result [source, queryresult] ---- -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| name | type | createStatement | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| "actor_fullname" | "NODE_KEY" | "CREATE CONSTRAINT `actor_fullname` FOR (n:`Actor`) REQUIRE (n.`firstname`, n.`surname`) IS KEY" | -| "author_name" | "NODE_PROPERTY_EXISTENCE" | "CREATE CONSTRAINT `author_name` FOR (n:`Author`) REQUIRE (n.`name`) IS NOT NULL" | -| "book_isbn" | "NODE_PROPERTY_UNIQUENESS" | "CREATE CONSTRAINT `book_isbn` FOR (n:`Book`) REQUIRE (n.`isbn`) IS UNIQUE" | -| "book_title_year" | "NODE_PROPERTY_UNIQUENESS" | "CREATE CONSTRAINT `book_title_year` FOR (n:`Book`) REQUIRE (n.`title`, n.`publicationYear`) IS UNIQUE" | -| "director_imdbId" | "NODE_KEY" | "CREATE CONSTRAINT `director_imdbId` FOR (n:`Director`) REQUIRE (n.`imdbId`) IS KEY" | -| "knows_since_how" | "RELATIONSHIP_KEY" | "CREATE CONSTRAINT `knows_since_how` FOR ()-[r:`KNOWS`]-() REQUIRE (r.`since`, r.`how`) IS KEY" | -| "movie_tagline" | "NODE_PROPERTY_TYPE" | "CREATE CONSTRAINT `movie_tagline` FOR (n:`Movie`) REQUIRE (n.`tagline`) IS :: STRING | LIST" | -| "movie_title" | "NODE_PROPERTY_TYPE" | "CREATE CONSTRAINT `movie_title` FOR (n:`Movie`) REQUIRE (n.`title`) IS :: STRING" | -| "node_uniqueness_param" | "NODE_PROPERTY_UNIQUENESS" | "CREATE CONSTRAINT `node_uniqueness_param` FOR (n:`Book`) REQUIRE (n.`prop1`) IS UNIQUE" | -| "ownershipId" | "RELATIONSHIP_KEY" | "CREATE CONSTRAINT `ownershipId` FOR ()-[r:`OWNS`]-() REQUIRE (r.`ownershipId`) IS KEY" | -| "part_of" | "RELATIONSHIP_PROPERTY_TYPE" | "CREATE CONSTRAINT `part_of` FOR ()-[r:`PART_OF`]-() REQUIRE (r.`order`) IS :: INTEGER" | -| "part_of_tags" | "RELATIONSHIP_PROPERTY_TYPE" | "CREATE CONSTRAINT `part_of_tags` FOR ()-[r:`PART_OF`]-() REQUIRE (r.`tags`) IS :: STRING | LIST" | -| "prequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "CREATE CONSTRAINT `prequels` FOR ()-[r:`PREQUEL_OF`]-() REQUIRE (r.`order`, r.`author`) IS UNIQUE" | -| "rel_exist_param" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "CREATE CONSTRAINT `rel_exist_param` FOR ()-[r:`WROTE`]-() REQUIRE (r.`published`) IS NOT NULL" | -| "sequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "CREATE CONSTRAINT `sequels` FOR ()-[r:`SEQUEL_OF`]-() REQUIRE (r.`order`) IS UNIQUE" | -| "wrote_year" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "CREATE CONSTRAINT `wrote_year` FOR ()-[r:`WROTE`]-() REQUIRE (r.`year`) IS NOT NULL" | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| name | type | createStatement | ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| "actor_fullname" | "NODE_KEY" | "CREATE CONSTRAINT `actor_fullname` FOR (n:`Actor`) REQUIRE (n.`firstname`, n.`surname`) IS KEY" | +| "author_name" | "NODE_PROPERTY_EXISTENCE" | "CREATE CONSTRAINT `author_name` FOR (n:`Author`) REQUIRE (n.`name`) IS NOT NULL" | +| "book_isbn" | "NODE_PROPERTY_UNIQUENESS" | "CREATE CONSTRAINT `book_isbn` FOR (n:`Book`) REQUIRE (n.`isbn`) IS UNIQUE" | +| "book_title_year" | "NODE_PROPERTY_UNIQUENESS" | "CREATE CONSTRAINT `book_title_year` FOR (n:`Book`) REQUIRE (n.`title`, n.`publicationYear`) IS UNIQUE" | +| "director_imdbId" | "NODE_KEY" | "CREATE CONSTRAINT `director_imdbId` FOR (n:`Director`) REQUIRE (n.`imdbId`) IS KEY" | +| "knows_since_how" | "RELATIONSHIP_KEY" | "CREATE CONSTRAINT `knows_since_how` FOR ()-[r:`KNOWS`]-() REQUIRE (r.`since`, r.`how`) IS KEY" | +| "movie_tagline" | "NODE_PROPERTY_TYPE" | "CREATE CONSTRAINT `movie_tagline` FOR (n:`Movie`) REQUIRE (n.`tagline`) IS :: STRING | LIST" | +| "movie_title" | "NODE_PROPERTY_TYPE" | "CREATE CONSTRAINT `movie_title` FOR (n:`Movie`) REQUIRE (n.`title`) IS :: STRING" | +| "node_uniqueness_param" | "NODE_PROPERTY_UNIQUENESS" | "CREATE CONSTRAINT `node_uniqueness_param` FOR (n:`Book`) REQUIRE (n.`prop1`) IS UNIQUE" | +| "node_vector_constraint" | "NODE_PROPERTY_TYPE" | "CREATE CONSTRAINT `node_vector_constraint` FOR (n:`Movie`) REQUIRE (n.`embedding`) IS :: VECTOR(42)" | +| "ownershipId" | "RELATIONSHIP_KEY" | "CREATE CONSTRAINT `ownershipId` FOR ()-[r:`OWNS`]-() REQUIRE (r.`ownershipId`) IS KEY" | +| "part_of" | "RELATIONSHIP_PROPERTY_TYPE" | "CREATE CONSTRAINT `part_of` FOR ()-[r:`PART_OF`]-() REQUIRE (r.`order`) IS :: INTEGER" | +| "part_of_tags" | "RELATIONSHIP_PROPERTY_TYPE" | "CREATE CONSTRAINT `part_of_tags` FOR ()-[r:`PART_OF`]-() REQUIRE (r.`tags`) IS :: STRING | LIST" | +| "prequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "CREATE CONSTRAINT `prequels` FOR ()-[r:`PREQUEL_OF`]-() REQUIRE (r.`order`, r.`author`) IS UNIQUE" | +| "rel_exist_param" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "CREATE CONSTRAINT `rel_exist_param` FOR ()-[r:`WROTE`]-() REQUIRE (r.`published`) IS NOT NULL" | +| "rel_vector_constraint" | "RELATIONSHIP_PROPERTY_TYPE" | "CREATE CONSTRAINT `rel_vector_constraint` FOR ()-[r:`CONTAINS`]-() REQUIRE (r.`embedding`) IS :: VECTOR(1536)" | +| "sequels" | "RELATIONSHIP_PROPERTY_UNIQUENESS" | "CREATE CONSTRAINT `sequels` FOR ()-[r:`SEQUEL_OF`]-() REQUIRE (r.`order`) IS UNIQUE" | +| "wrote_year" | "RELATIONSHIP_PROPERTY_EXISTENCE" | "CREATE CONSTRAINT `wrote_year` FOR ()-[r:`WROTE`]-() REQUIRE (r.`year`) IS NOT NULL" | ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ---- ====== @@ -1644,7 +1691,7 @@ label:default-output[] | MAP | createStatement -| Statement used to create the constraint. +| Statement used to create the constraint, or `null` if the constraint cannot be created through `CREATE CONSTRAINT` (for example in case of version incompatibilities). | STRING |=== @@ -1653,6 +1700,9 @@ label:default-output[] == DROP CONSTRAINT Constraints are dropped using the `DROP CONSTRAINT` command. +It is possible to drop constraints created in a different Cypher version than the one 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] @@ -1740,4 +1790,4 @@ DROP CONSTRAINT missing_constraint_name IF EXISTS `DROP CONSTRAINT missing_constraint_name IF EXISTS` has no effect. `missing_constraint_name` does not exist. ---- -====== \ No newline at end of file +====== diff --git a/modules/ROOT/pages/constraints/syntax.adoc b/modules/ROOT/pages/constraints/syntax.adoc index e85ed9854..a9edcaa92 100644 --- a/modules/ROOT/pages/constraints/syntax.adoc +++ b/modules/ROOT/pages/constraints/syntax.adoc @@ -19,7 +19,7 @@ If a name is not explicitly given, a unique name will be auto-generated. [NOTE] Creating a constraint requires the link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/database-administration/#access-control-database-administration-constraints[`CREATE CONSTRAINT` privilege]. -The `CREATE CONSTRAINT` command is optionally idempotent. +The `CREATE CONSTRAINT` command is optionally idempotent. This means its default behavior is to throw an error if an attempt is made to create the same constraint twice. With the `IF NOT EXISTS` flag, no error is thrown and nothing happens should a constraint with the same name or same schema and constraint type already exist. It may still throw an error if conflicting data, indexes, or constraints exist. @@ -122,6 +122,7 @@ Where `` is one of the following property types: * `ZONED DATETIME` * `DURATION` * `POINT` +* `VECTOR(DIMENSION)` label:cypher[Cypher 25 only] label:new[Introduced in Neo4j 2025.10] * `LIST` * `LIST` * `LIST` @@ -135,6 +136,11 @@ Where `` is one of the following property types: * `LIST` * Any closed dynamic union of the above types, e.g. `INTEGER | FLOAT | STRING`. +[NOTE] +Because storing lists of xref:values-and-types/vector.adoc[`VECTOR`] values is not supported, property type constraints cannot be created for `LIST(DIMENSION) NOT NULL>`. +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]. @@ -310,4 +316,4 @@ This means its default behavior is to throw an error if an attempt is made to dr With the `IF EXISTS` flag, no error is thrown and nothing happens should the constraint not exist. Instead, an informational notification is returned detailing that the constraint does not exist. -For examples on how to drop constraints, see xref:constraints/managing-constraints.adoc#drop-constraint[Create, show, and drop constraints -> DROP CONSTRAINT]. \ No newline at end of file +For examples on how to drop constraints, see xref:constraints/managing-constraints.adoc#drop-constraint[Create, show, and drop constraints -> DROP CONSTRAINT]. diff --git a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc index 17b72a476..7b227128c 100644 --- a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc +++ b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc @@ -85,6 +85,24 @@ RETURN vector_norm(vector([1.0, 5.0, 3.0, 6.7], 4, FLOAT), EUCLIDEAN) AS norm a| New xref:functions/vector.adoc#functions-vector_norm[`vector_norm()`] function, which returns 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`. +a| +label:functionality[] +label:new[] +[source, cypher, role="noheader"] +---- +CREATE CONSTRAINT node_vector_constraint +FOR (n:Movie) REQUIRE n.embedding IS :: VECTOR(42) +---- + +[source, cypher, role="noheader"] +---- +CREATE CONSTRAINT rel_vector_constraint +FOR ()-[r:CONTAINS]->() REQUIRE r.embedding IS :: VECTOR(1536) +---- + +a| Introduced `VECTOR` property type constraints. +For more information, see xref:constraints/managing-constraints.adoc#create-property-type-constraints[Create property type constraints]. + |=== === Updated in Cypher 25 @@ -250,7 +268,6 @@ RETURN n:$() | Added the ability to dynamically reference node labels and relationship types in places where xref:patterns/reference.adoc#label-expressions[label expressions] are allowed. |=== - [[cypher-deprecations-additions-removals-2025.06]] == Neo4j 2025.06