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/deprecations-additions-removals-compatibility.adoc
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,33 @@ Cypher 25 was introduced in Neo4j 2025.06 and can only be used on Neo4j 2025.06+
22
22
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.
23
23
For more information, see xref:queries/select-version.adoc[].
WHERE allReduce(acc = 0, node IN n \| acc + node.x, 6 < acc < 30)
42
+
RETURN [i IN n \| i.x] AS sequence
43
+
ORDER BY head(n).x, size(n)
44
+
----
45
+
46
+
| New xref:functions/predicate.adoc#functions-allreduce[`allReduce()`] function.
47
+
It enables the stepwise evaluation of a value accumulated over a path, allowing for early pruning of paths that do not satisfy a given predicate, and is optimized for path expansions.
| `allReduce(accumulator = initial, stepVariable IN list \| reductionFunction, predicate) :: BOOLEAN`
379
+
| Returns true if, during the stepwise evaluation of a value across the elements in a given `LIST<ANY>`, the accumulated result satisfies a specified predicate at every step, allowing for the early pruning of paths that do not meet the predicate. label:new[Introduced in Neo4j 2025.08]
@@ -107,7 +106,105 @@ RETURN all(i in emptyList WHERE true) as allTrue, all(i in emptyList WHERE false
107
106
108
107
======
109
108
109
+
[[functions-allreduce]]
110
+
[role=label--new-2025.08]
111
+
== allReduce()
110
112
113
+
.Details
114
+
|===
115
+
| *Syntax* 3+| `allReduce(accumulator = initial, stepVariable IN list \| reductionFunction, predicate)`
116
+
| *Description* 3+| Returns true if, during the stepwise evaluation of a value across the elements in a given LIST<ANY>, the accumulated result satisfies a specified predicate at every step, allowing for the early pruning of paths that do not meet the predicate.
| `accumulator` | `ANY` | A variable that holds the result of the `reductionFunction` as the `list` is iterated.
119
+
It is initialized with the value of `initial`.
120
+
| `initial` | `ANY` | The value of the `accumulator` for the first evaluation of `reductionFunction`.
121
+
| `stepVariable` | `ANY` | A variable that holds the value of each element of `list` during iteration.
122
+
| `list` | `LIST<ANY>` | The list that is being iterated over.
123
+
| `reductionFunction` | `ANY` | An expression whose return value becomes the next value of the `accumulator`.
124
+
The return type must match the return type of `initial`.
125
+
| `predicate` | `BOOLEAN` | A predicate that is evaluated for each iteration.
126
+
It has access to the variable `accumulator`, but not `stepVariable`.
127
+
| *Returns* 3+| `BOOLEAN`
128
+
|===
129
+
130
+
.Considerations
131
+
|===
132
+
| `allReduce()` differs from most Cypher functions because it iterates over a list, evaluating an expression for each element, rather than returning a result from a single evaluation.
133
+
| `allReduce()` combines the functionality of the xref:functions/predicate.adoc#functions-all[`all()`] and xref:functions/list.adoc#functions-reduce[`reduce()`] functions.
134
+
| If all evaluations of `predicate` are `true`, `allReduce()` will return `true`.
135
+
| If any evaluations of `predicate` are `false`, `allReduce()` will return `false`.
136
+
| `allReduce()` returns `true` if `list` is empty because there are no elements to falsify the `predicate`.
137
+
|===
138
+
139
+
.allReduce()
140
+
======
141
+
142
+
`allReduce()` is designed to optimize path expansions.
143
+
144
+
The below query finds `KNOWS` paths with a length of `3` where the cumulative age stays between `60` and `180`.
145
+
Paths exceeding this range at any step are pruned.
146
+
For example, a path starting with a node whose `age` value is less than `60` is automatically excluded, as is a path with a sequence such as `["Liam Neeson (70)", "Keanu Reeves (58)", "Kathryn Bigelow (71)"]` because its aggregated `age` value exceeds `180`.
147
+
148
+
.Find aggregated ages within a boundary
149
+
// tag::functions_predicate_allreduce_boundary[]
150
+
[source, cypher]
151
+
----
152
+
MATCH (()-[:KNOWS]-(n)){3}
153
+
WHERE allReduce(
154
+
acc = 0,
155
+
node IN n | acc + node.age,
156
+
60 < acc < 180)
157
+
RETURN [i IN n | i.name || " (" + toString(i.age) || ")"] AS ageSequence,
158
+
reduce(acc = 0, node IN n | acc + node.age) AS aggregatedAges
0 commit comments