Skip to content

Commit 738ebf4

Browse files
fix
2 parents b0fdb7d + 0513358 commit 738ebf4

26 files changed

+778
-217
lines changed

antora.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ nav:
77
asciidoc:
88
attributes:
99
neo4j-version: '5'
10-
neo4j-version-minor: '5.25'
11-
neo4j-version-exact: '5.25.1'
10+
neo4j-version-minor: '5.26'
11+
neo4j-version-exact: '5.26.0'

modules/ROOT/images/graph_match_clause.svg

Lines changed: 1 addition & 1 deletion
Loading

modules/ROOT/pages/appendix/gql-conformance/additional-cypher.adoc

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
:description: Information about Cypher features not included in GQL.
2+
:test-skip: true
23
= Additional Cypher features
34

45
While the link:https://www.iso.org/standard/76120.html[GQL Standard] incorporates a lot of capabilities in Cypher, Cypher contains additional features that are not part of GQL and no GQL alternatives currently exist for them.
@@ -78,6 +79,93 @@ Either the pattern already exists, or it needs to be created.
7879
| Syntactic construct for creating a `LIST` based on matchings of a pattern.
7980
|===
8081

82+
[[dynamic-queries]]
83+
== Dynamic queries
84+
85+
Node labels, relationship types, properties, and CSV columns can be referenced dynamically using Cypher.
86+
This allows for more flexible queries and mitigates the risk of Cypher injection.
87+
(For more information about Cypher injection, see link:https://neo4j.com/developer/kb/protecting-against-cypher-injection/[Neo4j Knowledge Base -> Protecting against Cypher injection]).
88+
89+
[options="header", cols="2a,5a"]
90+
|===
91+
| Cypher feature
92+
| Description
93+
94+
a|
95+
[source, cypher, role="noheader"]
96+
----
97+
MATCH (n:$($label)),
98+
()-[r:$($type)]->()
99+
----
100+
101+
| xref:clauses/match.adoc#dynamic-match[`MATCH` nodes and relationships using dynamic node labels and relationship types]
102+
103+
a|
104+
[source, cypher, role="noheader"]
105+
----
106+
CREATE (n:$($label)),
107+
()-[r:$($type)]->()
108+
----
109+
110+
| xref:clauses/create.adoc#dynamic-create[`CREATE` nodes and relationships using dynamic node labels and relationship types]
111+
112+
a|
113+
[source, cypher, role="noheader"]
114+
----
115+
MERGE (n:$($label)),
116+
()-[r:$($type)]->()
117+
----
118+
119+
| xref:clauses/merge.adoc#dynamic-merge[`MERGE` nodes and relationships using dynamic node labels and relationship types]
120+
121+
a|
122+
[source, cypher, role="noheader"]
123+
----
124+
LOAD CSV WITH HEADERS FROM 'file:///artists-with-headers.csv' AS line
125+
CREATE (n:$(line.label) {name: line.Name})
126+
----
127+
128+
| xref:clauses/load-csv.adoc#dynamic-columns[Import CSV files using dynamic columns]
129+
130+
131+
a|
132+
[source, cypher, role="noheader"]
133+
----
134+
MATCH (n)
135+
SET n[$key] = value
136+
----
137+
138+
| xref:clauses/set.adoc#dynamic-set-property[Dynamically `SET` or update a property]
139+
140+
a|
141+
[source, cypher, role="noheader"]
142+
----
143+
MATCH (n:Label)
144+
SET n:$(n.property)
145+
----
146+
147+
| xref:clauses/set.adoc#dynamic-set-node-label[Dynamically `SET` a node label]
148+
149+
a|
150+
[source, cypher, role="noheader"]
151+
----
152+
MATCH (n {name: 'Peter'})
153+
REMOVE n:$($label)
154+
----
155+
156+
| xref:clauses/remove.adoc#dynamic-remove-property[Dynamically `REMOVE` a property]
157+
158+
a|
159+
[source, cypher, role="noheader"]
160+
----
161+
MATCH (n {name: 'Peter'})
162+
REMOVE n:$($label)
163+
----
164+
165+
| xref:clauses/remove.adoc#dynamic-remove-node-label[Dynamically `REMOVE` a node label]
166+
167+
|===
168+
81169

82170
[[functions]]
83171
== Functions
@@ -118,7 +206,10 @@ Either the pattern already exists, or it needs to be created.
118206
| Description
119207

120208
| xref:functions/graph.adoc#functions-graph-by-elementid[`graph.byElementId()`]
121-
| Returns the graph reference with the given element id. It is only supported in the `USE` clause, on composite databases.
209+
| Returns the graph reference with the given element id.
210+
It is only supported in the xref:clauses/use.adoc[`USE`] clause.
211+
As of Neo4j 5.26, it is supported on both link:{neo4j-docs-base-uri}/operations-manual/{page-version}/database-administration/[standard and composite databases].
212+
On earlier versions, it is only supported on composite databases.
122213

123214
| xref:functions/graph.adoc#functions-graph-byname[`graph.byName()`]
124215
| Returns the graph reference of the given name. It is only supported in the `USE` clause, on composite databases.

modules/ROOT/pages/clauses/create.adoc

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,63 @@ Nodes created: 2 +
205205
Properties set: 4
206206
|===
207207

208+
[role=label--new-5.26]
209+
[[dynamic-create]]
210+
== CREATE using dynamic node labels and relationship types
211+
212+
Node labels and relationship types can be referenced dynamically in expressions, parameters, and variables when creating nodes and relationships.
213+
This allows for more flexible queries and mitigates the risk of Cypher injection.
214+
(For more information about Cypher injection, see link:https://neo4j.com/developer/kb/protecting-against-cypher-injection/[Neo4j Knowledge Base -> Protecting against Cypher injection]).
215+
216+
.Syntax for creating nodes and relationships dynamically
217+
[source, syntax]
218+
----
219+
CREATE (n:$(<expr>))
220+
CREATE ()-[r:$(<expr>)]->()
221+
----
222+
223+
The expression must evaluate to a `STRING NOT NULL | LIST<STRING NOT NULL> NOT NULL` value.
224+
Using a `LIST<STRING>` with more than one item when creating a relationship using dynamic relationship types will fail.
225+
This is because a relationship can only have exactly one type.
226+
227+
.Parameters
228+
[source, parameters]
229+
----
230+
{
231+
"nodeLabels": ["Person", "Director"],
232+
"relType": "DIRECTED",
233+
"movies": ["Ladybird", "Little Women", "Barbie"]
234+
}
235+
----
236+
237+
.Create nodes and relationships using dynamic node labels and relationship types
238+
// tag::clauses_create_dynamic_create[]
239+
[source, cypher]
240+
----
241+
CREATE (greta:$($nodeLabels) {name: 'Greta Gerwig'})
242+
WITH greta
243+
UNWIND $movies AS movieTitle
244+
CREATE (greta)-[rel:$($relType)]->(m:Movie {title: movieTitle})
245+
RETURN greta.name AS name, labels(greta) AS labels, type(rel) AS relType, collect(m.title) AS movies
246+
----
247+
// end::clauses_create_dynamic_create[]
248+
249+
.Result
250+
[role="queryresult",options="footer",cols="4*<m"]
251+
|===
252+
| name | labels | relType | movies
253+
254+
| "Greta Gerwig"
255+
| ["Person", "Director"]
256+
| "DIRECTED"
257+
| ["Ladybird", "Little Women", "Barbie"]
258+
4+d|Rows: 1 +
259+
|===
260+
208261
[role=label--new-5.18]
209262
[[insert-as-synonym-of-create]]
210263
== `INSERT` as a synonym of `CREATE`
211-
264+
212265
`INSERT` can be used as a synonym to `CREATE` for creating nodes and relationships, and was introduced as part of Cypher's xref:appendix/gql-conformance/index.adoc[].
213266
However, `INSERT` requires that multiple labels are separated by an ampersand `&` and not by colon `:`.
214267

modules/ROOT/pages/clauses/listing-settings.adoc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,13 @@ For a full list of all available settings in Neo4j, refer to link:{neo4j-docs-ba
180180
== Listing settings with filtering on output columns
181181

182182
The listed settings can be filtered by using the `WHERE` clause.
183-
For example, the following query returns the name, value, and description of the first three settings starting with 'dbms':
183+
For example, the following query returns the name, value, and description of the first three settings starting with 'server':
184184

185185
.Query
186186
[source, cypher]
187187
----
188188
SHOW SETTINGS YIELD name, value, description
189-
WHERE name STARTS WITH 'dbms'
189+
WHERE name STARTS WITH 'server'
190190
RETURN name, value, description
191191
LIMIT 3
192192
----
@@ -196,17 +196,17 @@ LIMIT 3
196196
|===
197197
| name | value | description
198198

199-
| "dbms.cluster.catchup.client_inactivity_timeout"
200-
| "10m"
201-
| "The catchup protocol times out if the given duration elapses with no network activity. Every message received by the client from the server extends the timeout duration."
199+
| "server.backup.enabled"
200+
| "true"
201+
| "Enable support for running online backups."
202202

203-
| "dbms.cluster.discovery.endpoints"
204-
| null
205-
| "A comma-separated list of endpoints that a server should contact in order to discover other cluster members. Typically, all cluster members, including the current server, must be specified in this list. The setting configures the endpoints for Discovery service V1."
203+
| "server.backup.exec_connector.command"
204+
| ""
205+
| "Command to execute for ExecDataConnector list"
206206

207-
| "dbms.cluster.discovery.log_level"
208-
| "WARN"
209-
| "The level of middleware logging."
207+
| "server.backup.exec_connector.scheme"
208+
| ""
209+
| "Schemes ExecDataConnector will match on"
210210

211211
3+d|Rows: 3
212212
|===

modules/ROOT/pages/clauses/load-csv.adoc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,48 @@ Added 4 nodes, Set 8 properties, Added 4 labels
299299
|===
300300
====
301301

302+
[role=label--new-5.26]
303+
[[dynamic-columns]]
304+
=== Import CSV files using dynamic columns
305+
306+
CSV columns can be referenced dynamically to map labels to nodes in the graph.
307+
This enables flexible data handling, allowing labels to be be populated from CSV column values without manually specifying each entry.
308+
It also mitigates the risk of Cypher injection.
309+
(For more information about Cypher injection, see link:https://neo4j.com/developer/kb/protecting-against-cypher-injection/[Neo4j Knowledge Base -> Protecting against Cypher injection]).
310+
311+
.bands-with-headers.csv
312+
[source, csv, filename="bands-with-headers.csv"]
313+
----
314+
Id,Label,Name
315+
1,Band,The Beatles
316+
2,Band,The Rolling Stones
317+
3,Band,Pink Floyd
318+
4,Band,Led Zeppelin
319+
----
320+
321+
.Query
322+
// tag::clauses_load_csv_dynamic_columns[]
323+
[source, cypher]
324+
----
325+
LOAD CSV WITH HEADERS FROM 'file:///bands-with-headers.csv' AS line
326+
MERGE (n:$(line.Label) {name: line.Name})
327+
RETURN n AS bandNodes
328+
----
329+
// end::clauses_load_csv_dynamic_columns[]
330+
331+
.Result
332+
[role="queryresult",options="header,footer",cols="1*<m"]
333+
|===
334+
| bandNodes
335+
336+
| (:Band {name: 'The Beatles'})
337+
| (:Band {name: 'The Rolling Stones'})
338+
| (:Band {name: 'Pink Floyd'})
339+
| (:Band {name: 'Led Zeppelin'})
340+
341+
1+d|Rows: 4 +
342+
Added 4 nodes, Set 4 properties, Added 4 labels
343+
|===
302344

303345
=== Import compressed CSV files
304346

0 commit comments

Comments
 (0)