You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/ROOT/pages/directives/indexes-and-constraints.adoc
+10-13Lines changed: 10 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,12 +18,11 @@ directive @unique(
18
18
) on FIELD_DEFINITION
19
19
----
20
20
21
-
Using this directive does not automatically ensure the existence of these constraints, and you will need to run a function on server startup.
22
-
See the section xref::/directives/indexes-and-constraints.adoc#_asserting_constraints[Asserting constraints] for details.
21
+
Using this directive does not automatically ensure the existence of these constraints, and you will need to create them manually.
23
22
24
23
=== Usage
25
24
26
-
`@unique` directives can only be used in GraphQL object types representing nodes, and they are only applicable for the "main" label for the node.
25
+
`@unique` directives can only be used in GraphQL object types representing nodes, for any label specified on them.
27
26
28
27
In the following example, a unique constraint is asserted for the label `Colour` and the property `hexadecimal`:
29
28
@@ -53,7 +52,7 @@ type Colour @node(labels: ["Color"]) {
53
52
----
54
53
55
54
In the following example, all labels specified in the `labels` argument of the `@node` directive are also checked when asserting constraints.
56
-
If there is a unique constraint specified for the `hexadecimal` property of nodes with the `Hue` label, but not the `Color` label, no error is thrown and no new constraints are created when running `assertIndexesAndConstraints`.
55
+
If there is a unique constraint specified for the `hexadecimal` property of nodes with the `Hue` label, but not the `Color` label, no error is thrown when running `assertIndexesAndConstraints`.
57
56
58
57
[source, graphql, indent=0]
59
58
----
@@ -64,7 +63,7 @@ type Colour @node(labels: ["Color", "Hue"]) {
64
63
65
64
== Fulltext indexes
66
65
67
-
You can use the `@fulltext` directive to add a https://neo4j.com/docs/cypher-manual/current/indexes-for-full-text-search/[Full text index] inside Neo4j.
66
+
You can use the `@fulltext` directive to specify a https://neo4j.com/docs/cypher-manual/current/indexes-for-full-text-search/[full-text index] inside Neo4j.
68
67
For example:
69
68
70
69
[source, graphql, indent=0]
@@ -82,13 +81,12 @@ directive @fulltext(indexes: [FullTextInput]!) on OBJECT
82
81
----
83
82
84
83
Using this directive does not automatically ensure the existence of these indexes.
85
-
You need to run a function on server startup.
86
-
See the section xref::/directives/indexes-and-constraints.adoc#_asserting_constraints[Asserting constraints] for details.
84
+
They must be created manually.
87
85
88
86
=== Specifying
89
87
90
88
The `@fulltext` directive can be used on nodes.
91
-
In this example, a `Fulltext` index called "ProductName", for the name `field`, on the `Product` node, is added:
89
+
In this example, a full-text index called "ProductName", for the name `field`, on the `Product` node, is specified:
When you run xref::/directives/indexes-and-constraints.adoc#_asserting_constraints[Asserting constraints], they create the index like so:
99
+
This index can be created in the database by running the following Cypher:
102
100
103
101
[source, cypher, indent=0]
104
102
----
@@ -224,8 +222,8 @@ query {
224
222
== Asserting constraints
225
223
226
224
In order to ensure that the specified constraints exist in the database, you need to run the function `assertIndexesAndConstraints`.
227
-
A simple example to create the necessary constraints might look like the following, assuming a valid driver instance in the variable `driver`.
228
-
This creates two constraints, one for each field decorated with `@id` and `@unique`, and apply the indexes specified in `@fulltext`:
225
+
A simple example to check for the existence of the necessary constraints might look like the following, assuming a valid driver instance in the variable `driver`.
226
+
This checks for the unique node property constraint for the field decorated `@unique`, and checks for the index specified in `@fulltext`:
0 commit comments