Skip to content

Commit 346f4c7

Browse files
post-review editorial
1 parent b62f65f commit 346f4c7

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

modules/ROOT/pages/functions/index.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ These functions return either true or false for the given arguments.
376376

377377
1.1+| xref::functions/predicate.adoc#functions-allreduce[`allReduce()`]
378378
| `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]
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.
380+
Where that list is a group variable defined in a quantified path pattern, it allows for the early pruning of paths that do not satisfy the predicate. label:new[Introduced in Neo4j 2025.08]
380381

381382
1.1+| xref::functions/predicate.adoc#functions-any[`any()`]
382383
| `any(variable :: ANY, list :: LIST<ANY>, predicate :: ANY) :: BOOLEAN`

modules/ROOT/pages/functions/predicate.adoc

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ RETURN all(i in emptyList WHERE true) as allTrue, all(i in emptyList WHERE false
109109
.Details
110110
|===
111111
| *Syntax* 3+| `allReduce(accumulator = initial, stepVariable IN list \| reductionFunction, predicate)`
112-
| *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.
112+
| *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.
113+
Where that list is a xref:patterns/variable-length-patterns.adoc#group-variables[group variable] defined in a xref:patterns/variable-length-patterns.adoc#quantified-path-patterns[quantified path pattern], it allows for the early pruning of paths that do not satisfy the predicate.
113114
.7+| *Arguments* | *Name* | *Type* | *Description*
114115
| `accumulator` | `ANY` | A variable that holds the result of the `reductionFunction` as the `list` is iterated.
115116
It is initialized with the value of `initial`.
@@ -135,24 +136,21 @@ It has access to the variable `accumulator`, but not `stepVariable`.
135136
.allReduce()
136137
======
137138
138-
`allReduce()` is designed to optimize path expansions.
139-
140-
The below query finds `KNOWS` paths with a length of `3` where the cumulative age stays between `60` and `190`.
141-
Paths exceeding this range at any step are pruned.
142-
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 `190`.
139+
The below query finds `KNOWS` paths with a length of `3` where the `accumulator` begins with first node's `age` and the accumulated `age` values of all nodes in the path never exceeds `230`.
140+
Paths that do not meet this requirement are excluded, such as the path with the sequence `["Keanu Reeves (58)", "Carrie Anne Moss (55)", "Guy Pearce (55)", "Liam Neeson (70)"]` which has an aggregated `age` value of `238`.
143141
144142
.Find aggregated ages within a boundary
145143
// tag::functions_predicate_allreduce_boundary[]
146144
[source, cypher]
147145
----
148-
MATCH (()-[:KNOWS]-(n)){3}
146+
MATCH (s) (()-[:KNOWS]-(n)){3}
149147
WHERE allReduce(
150-
acc = 0,
148+
acc = s.age,
151149
node IN n | acc + node.age,
152-
60 < acc < 190
150+
acc < 230
153151
)
154-
RETURN [i IN n | i.name || " (" + toString(i.age) || ")"] AS ageSequence,
155-
reduce(acc = 0, node IN n | acc + node.age) AS aggregatedAges
152+
RETURN [i IN [s] + n | i.name || " (" + toString(i.age) || ")"] AS ageSequence,
153+
reduce(acc = 0, node IN [s] + n | acc + node.age) AS aggregatedAges
156154
ORDER BY aggregatedAges
157155
----
158156
// end::functions_predicate_allreduce_boundary[]
@@ -162,15 +160,14 @@ ORDER BY aggregatedAges
162160
|===
163161
| ageSequence | aggregatedAges
164162
165-
| ["Liam Neeson (70)", "Guy Pearce (55)", "Carrie Anne Moss (55)"] | 180
166-
| ["Liam Neeson (70)", "Keanu Reeves (58)", "Carrie Anne Moss (55)"] | 183
167-
| ["Kathryn Bigelow (71)", "Keanu Reeves (58)", "Carrie Anne Moss (55)"] | 184
163+
| ["Carrie Anne Moss (55)", "Keanu Reeves (58)", "Kathryn Bigelow (71)", "Jessica Chastain (45)"] | 229
164+
| ["Jessica Chastain (45)", "Kathryn Bigelow (71)", "Keanu Reeves (58)", "Carrie Anne Moss (55)"] | 229
168165
169-
2+d|Rows: 3
166+
2+d|Rows: 2
170167
|===
171168
172-
The next query uses `alReduce()` to compare neighboring relationships.
173-
It finds KNOWS paths with a length of at least `3` where each relationship’s `since` value is greater than the previous one and above `2000`.
169+
The next query uses `allReduce()` to compare neighboring relationships.
170+
It finds `KNOWS` paths with a length of at least `3` where each relationship’s `since` value is greater than the previous one and above `2000`.
174171
175172
.Find paths where a relationship property must be above a value and increase along a path
176173
// tag::functions_predicate_allreduce_relationship_values[]

0 commit comments

Comments
 (0)