Skip to content

Commit e0efb32

Browse files
editorial fixes
1 parent ec2a18a commit e0efb32

File tree

6 files changed

+60
-19
lines changed

6 files changed

+60
-19
lines changed

modules/ROOT/images/match-modes-reference.svg

Lines changed: 4 additions & 5 deletions
Loading

modules/ROOT/pages/clauses/match.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Unlike a node pattern, a relationship pattern cannot be used in a `MATCH` clause
150150
For more information about relationship patterns, see xref:patterns/fixed-length-patterns#relationship-patterns[Patterns -> Relationship patterns].
151151

152152
[NOTE]
153-
Cypher default match mode, `DIFFERENT RELATIONSHIPS`, will by default only match a relationship once inside a single pattern.
153+
Cypher default match mode, `DIFFERENT RELATIONSHIPS`, will only match a relationship once inside a single pattern.
154154
The same is not true for the `REPEATABLE ELEMENTS` match mode.
155155
For more information, see xref::patterns/match-modes.adoc[Match modes]
156156

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,48 @@ Replacement syntax for deprecated and removed features are also indicated.
2121
Cypher 25 was introduced in Neo4j 2025.06 and can only be used on Neo4j 2025.06+ databases.
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

24+
[[cypher-deprecations-additions-removals-2025.xx]]
25+
== Neo4j 2025.xx
26+
27+
=== New in Cypher 25
28+
29+
[cols="2", options="header"]
30+
|===
31+
| Feature
32+
| Details
33+
34+
35+
a|
36+
label:functionality[]
37+
label:new[]
38+
[source, cypher, role="noheader"]
39+
----
40+
MATCH REPEATABLE ELEMENTS p = (:B)-->{,5}()
41+
RETURN [n IN nodes(p) \| n.q] AS nodes
42+
----
43+
44+
45+
|
46+
New match mode, xref:patterns/match-modes.adoc#repeatable-elements[`REPEATABLE ELEMENTS`].
47+
This is a non-restrictive match mode, in which relationships matched across all constituent path patterns in a graph patterns can be repeatedly traversed.
48+
49+
50+
a|
51+
label:functionality[]
52+
label:new[]
53+
[source, cypher, role="noheader"]
54+
----
55+
MATCH DIFFERENT RELATIONSHIPS p = (:B)-->{,5}()
56+
RETURN [n IN nodes(p) \| n.q] AS nodes
57+
----
58+
59+
a|
60+
New keyword, xref:patterns/match-modes.adoc#different-relationships[`DIFFERENT RELATIONSHIPS`], which enables explicitly specifying Cypher's default mode.
61+
This is a restrictive match mode, which requires that all relationships matched across all constituent path patterns in a graph pattern must be unique.
62+
Specifying `DIFFERENT RELATIONSHIPS` is functionally equivalent to not specifying a match mode.
63+
64+
|===
65+
2466
[[cypher-deprecations-additions-removals-2025.06]]
2567
== Neo4j 2025.06
2668

modules/ROOT/pages/patterns/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This chapter includes the following sections:
2626
* xref:patterns/variable-length-patterns.adoc[] - information about quantified path patterns, quantified relationships, and group variables.
2727
* xref:patterns/shortest-paths.adoc[] - information about finding the `SHORTEST` path patterns.
2828
* xref:patterns/non-linear-patterns.adoc[] - information about equijoins and graph patterns (combined path patterns).
29-
* xref:patterns/match-modes.adoc[] - information about Cypher's different match modes, which which determine whether relationships can appear more than once in a graph pattern match.
29+
* xref:patterns/match-modes.adoc[] - information about Cypher's different match modes, which determine whether relationships can appear more than once in a graph pattern match.
3030
* xref:patterns/reference.adoc[] - a reference for looking up the syntax and semantics of graph pattern matching.
3131
3232
The model data in the examples used in this chapter are based on the UK national rail network, using https://www.raildeliverygroup.com/our-services/rail-data/fares-timetable-data.html[publicly available datasets].

modules/ROOT/pages/patterns/match-modes.adoc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
:table-caption!:
33
= Match modes
44

5-
Match modes determine whether relationships can appear more than once in a graph pattern match.
6-
Cypher offers two match modes:
5+
Match modes determine whether relationships can appear more than once in a graph pattern match (nodes can appear multiple times regardless of the match mode).
6+
Cypher contains two match modes:
77

88
* xref:patterns/match-modes.adoc#different-relationships[`DIFFERENT RELATIONSHIPS`]: a relationship can only be traversed once in a given match for a graph pattern.
99
The same restriction does not hold for nodes, which may be re-traversed any number of times in a matched path.
@@ -14,7 +14,7 @@ This match mode is required in order for paths to be able to traverse a relation
1414
[[example-graph]]
1515
== Example graph
1616

17-
To explain match modes, this page will use the scenario of the link:https://en.wikipedia.org/wiki/Seven_Bridges_of_K%C3%B6nigsberg[seven bridges of Königsberg], a problem studied by link:https://en.wikipedia.org/wiki/Leonhard_Euler[Leonhard Euler] in 1736 to determine if one could cross all seven bridges of Königsberg exactly once and return to the same starting location.
17+
To explain match modes, this page will use the scenario of the link:https://en.wikipedia.org/wiki/Seven_Bridges_of_K%C3%B6nigsberg[Seven bridges of Königsberg], a problem studied by link:https://en.wikipedia.org/wiki/Leonhard_Euler[Leonhard Euler] in 1736 to determine if one could cross all seven bridges of Königsberg exactly once.
1818

1919
image::match-modes-graph.svg[Graph showing the seven bridges of Königsberg, width=600, role=popup]
2020

@@ -134,7 +134,7 @@ In the `DIFFERENT RELATIONSHIPS` match mode, each step must use a unique bridge.
134134
After the first step, one bridge is used, leaving 6 remaining bridges to be used in the subsequent steps.
135135
Once all 6 remaining bridges are traversed, a 7th step would require re-traversing a bridge, which is not allowed.
136136

137-
This reflects the conclusion of Euler’s seven bridges of Königsberg problem: the impossibility of crossing each bridge exactly once and returning to the same starting point.
137+
This reflects the conclusion of Euler’s seven bridges of Königsberg problem: the impossibility of crossing each bridge exactly once.
138138
The below query demonstrates this impossibility.
139139
More specifically, it tries to find a path where each bridge is crossed exactly once with a length of `7` relationships, starting and ending at the same `Location`, `Kneiphof`.
140140

@@ -156,7 +156,7 @@ RETURN [n IN nodes(p) | n.name] AS visitedLocations,
156156
(no results)
157157
----
158158

159-
No results are returned because, when using the DIFFERENT RELATIONSHIPS match mode, it is impossible to traverse all 7 relationships once without any re-traversals, which is not allowed.
159+
No results are returned because, when using the `DIFFERENT RELATIONSHIPS` match mode, it is impossible to traverse all 7 relationships once without any re-traversals, which is not allowed.
160160

161161
For more information about this match mode, see xref:patterns/reference.adoc#match-modes-rules-different-relationships[Syntax & semantics -> `DIFFERENT RELATIONSHIPS`].
162162

@@ -165,11 +165,11 @@ For more information about this match mode, see xref:patterns/reference.adoc#mat
165165
== REPEATABLE ELEMENTS
166166

167167
The `REPEATABLE ELEMENTS` match mode ensures that there are no restrictions on how many times a node or relationship can occur for a given `MATCH` result.
168-
In so doing, the `REPEATABLE ELEMENTS` match mode does not solve the impossibility of crossing every bridge in Köningsberg exactly once and returning to the starting location.
168+
In so doing, the `REPEATABLE ELEMENTS` match mode does not solve the impossibility of crossing every bridge in Königsberg exactly once.
169169
However, the ability to re-traverse relationships does allow Cypher to return paths when testing Euler’s hypothesis.
170170

171171
[NOTE]
172-
Queries utilizing this match mode must specify the `REPEATABLE ELEMENTS` keyword after the MATCH.
172+
Queries utilizing this match mode must specify the `REPEATABLE ELEMENTS` keyword after `MATCH`.
173173

174174
The following example re-runs the above query, matching paths where each Königsberg bridge is crossed before returning the starting location
175175
However, this time the query uses the match mode `REPEATABLE ELEMENTS`.
@@ -231,12 +231,12 @@ RETURN count(p) AS pathCount
231231
1+d|Rows: 1
232232
|===
233233

234-
If the path length is increased to exactly `10`, a total of `5580` paths are returned, `11` returns `54144`, `12` returns `229824`, and so on, without limit.
234+
If the path length is increased to exactly `10`, a total of `5580` paths are returned, `11` hops returns `54144` paths, `12` hops returns `229824` paths, and so on, without limit.
235235

236236
To ensure that a `MATCH` will return a finite number of solutions in a finite amount of time, xref:patterns/reference.adoc#quantifiers-rules#quantifiers-rules[unbounded quantifiers] that do not impose an upper bound on a pattern, such as `*`, `+`, or `{1,}` are not allowed in combination with `REPEATABLE ELEMENTS`.
237237
Also, users should take into account that the number of results returned for a high number of repetitions can significantly impact both memory usage and the speed of the query.
238238

239-
.Not allowed: Find paths of an unbounded length using REPEATABLE ELEMENTS
239+
.Not allowed: find paths of an unbounded length using `REPEATABLE ELEMENTS`
240240
[source, cypher, role=test-fail]
241241
----
242242
MATCH REPEATABLE ELEMENTS p = (start:Location {name: 'Kneiphof'})-[:BRIDGE]-+(start)

modules/ROOT/pages/patterns/reference.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,7 +1706,7 @@ This restriction is required to prevent a a potentially infinite number of retur
17061706
[[match-modes-rules-clauses-subqueries]]
17071707
==== Clauses and subqueries
17081708

1709-
Match modes can only be used after `MATCH`.
1709+
Match modes can only be specified after `MATCH`.
17101710
They cannot be applied to a xref:clauses/merge.adoc[`MERGE`] clause.
17111711

17121712
Match modes are allowed in the xref:subqueries/collect.adoc[`COLLECT`], xref:subqueries/count.adoc[`COUNT`], and xref:subqueries/existential.adoc[`EXISTS`] subqueries after a `MATCH` clause.
@@ -1830,7 +1830,7 @@ The `DIFFERENT RELATIONSHIPS` match mode allows only nodes to recur in a path.
18301830
.Match a pattern with a length of `5` relationships using the `DIFFERENT RELATIONSHIPS` match mode
18311831
[source, cypher]
18321832
----
1833-
MATCH p = (:B)->{5}()
1833+
MATCH p = (:B)-->{5}()
18341834
RETURN [n IN nodes(p) | n.q] AS nodes
18351835
----
18361836

@@ -1850,7 +1850,7 @@ The `REPEATABLE ELEMENTS` match mode allows both nodes and relationships to be r
18501850
.Match a pattern with a length of `5` relationships using the `REPEATABLE ELEMENTS` match mode
18511851
[source, cypher]
18521852
----
1853-
MATCH REPEATABLE ELEMENTS p = (:B)->{5}()
1853+
MATCH REPEATABLE ELEMENTS p = (:B)-->{5}()
18541854
RETURN [n IN nodes(p) | n.q] AS nodes
18551855
----
18561856

0 commit comments

Comments
 (0)