From 73f1ddd2c091f705c2c7752fdd3be374cdc33ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Pryce-=C3=85klundh?= <112686610+JPryce-Aklundh@users.noreply.github.com> Date: Wed, 18 Jun 2025 10:09:16 +0200 Subject: [PATCH 1/3] match modes and next --- modules/ROOT/pages/patterns/match-modes.adoc | 4 ++++ .../queries/composed-queries/sequential-queries.adoc | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/modules/ROOT/pages/patterns/match-modes.adoc b/modules/ROOT/pages/patterns/match-modes.adoc index 29b283bc6..19735f1eb 100644 --- a/modules/ROOT/pages/patterns/match-modes.adoc +++ b/modules/ROOT/pages/patterns/match-modes.adoc @@ -55,12 +55,14 @@ To show the behavior of `DIFFERENT RELATIONSHIPS`, consider the following query, The relationships used in this query are directional, meaning paths are traversed following specific directions for each bridge (`-[:BRIDGE]\->`). .Find paths with a length of 5 relationships from a start node +// tag::patterns_match_modes_different_relationships[] [source, cypher] ---- MATCH p = (:Location {name: 'Kneiphof'})-[:BRIDGE]->{5}() RETURN [n IN nodes(p) | n.name] AS locations, [r IN relationships(p) | r.id] AS crossedBridges // <1> ---- +// end::patterns_match_modes_different_relationships[] <1> The xref:expressions/list-expressions.adoc#list-comprehension[list comprehensions] iterate over nodes and relationships in a path and return specific properties (the `name` property from nodes, and the `id` property from relationships). @@ -153,6 +155,7 @@ Queries utilizing this match mode must specify the `REPEATABLE ELEMENTS` keyword The following query matches the graph for paths with a length of `7` relationships using `REPEATABLE ELEMENTS` and returns a sample path. .Find a path with a length of 7 relationships using `REPEATABLE ELEMENTS` +// tag::patterns_match_modes_repeatable_elements[] [source, cypher] ---- MATCH REPEATABLE ELEMENTS p = (:Location {name: 'Kneiphof'})-[:BRIDGE]-{7}() @@ -160,6 +163,7 @@ WITH collect(p)[0] AS samplePath RETURN [n IN nodes(samplePath) | n.name] AS samplePathLocations, [r IN relationships(samplePath) | r.id] AS samplePathBridges ---- +// end::patterns_match_modes_repeatable_elements[] .Result [role="queryresult",options="header,footer",cols="2*(p:Product {name: 'Chocolate'}) @@ -119,6 +120,7 @@ NEXT RETURN customer.firstName AS chocolateCustomer, product.price * (1 - customer.discount) AS chocolatePrice ---- +// end::sequential_queries_basic_example[] .Result [role="queryresult",options="header,footer",cols="2*(:Product)<-[:SUPPLIES]-(s:Supplier) @@ -227,6 +233,7 @@ WHEN size(personalities) > 1 THEN ELSE RETURN customer, personalities[0] AS personality ---- +// end::sequential_queries_chaining_conditional_queries[] .Result [role="queryresult",options="header,footer",cols="2*(p:Product) @@ -273,6 +281,7 @@ ELSE { RETURN customer.firstName AS customer, "club below 1000" AS customerType, finalSum AS sum } ---- +// end::sequential_queries_in_conditional_queries[] .Result [role="queryresult",options="header,footer",cols="3* Date: Wed, 18 Jun 2025 13:03:39 +0200 Subject: [PATCH 2/3] Update modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc Co-authored-by: Richard Sill <156673635+rsill-neo4j@users.noreply.github.com> --- .../ROOT/pages/queries/composed-queries/sequential-queries.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc b/modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc index 2f53b4cec..02201607e 100644 --- a/modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc +++ b/modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc @@ -180,7 +180,7 @@ NEXT RETURN p.name as product, customers ---- -// end::sequential_queries_next_call[] +// end::sequential_queries_call[] ====== ==== From 9995aa291260f24e80f984951375f607a6e86a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Pryce-=C3=85klundh?= <112686610+JPryce-Aklundh@users.noreply.github.com> Date: Wed, 18 Jun 2025 13:32:01 +0200 Subject: [PATCH 3/3] change query --- modules/ROOT/pages/patterns/match-modes.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ROOT/pages/patterns/match-modes.adoc b/modules/ROOT/pages/patterns/match-modes.adoc index 19735f1eb..57b941c34 100644 --- a/modules/ROOT/pages/patterns/match-modes.adoc +++ b/modules/ROOT/pages/patterns/match-modes.adoc @@ -55,14 +55,12 @@ To show the behavior of `DIFFERENT RELATIONSHIPS`, consider the following query, The relationships used in this query are directional, meaning paths are traversed following specific directions for each bridge (`-[:BRIDGE]\->`). .Find paths with a length of 5 relationships from a start node -// tag::patterns_match_modes_different_relationships[] [source, cypher] ---- MATCH p = (:Location {name: 'Kneiphof'})-[:BRIDGE]->{5}() RETURN [n IN nodes(p) | n.name] AS locations, [r IN relationships(p) | r.id] AS crossedBridges // <1> ---- -// end::patterns_match_modes_different_relationships[] <1> The xref:expressions/list-expressions.adoc#list-comprehension[list comprehensions] iterate over nodes and relationships in a path and return specific properties (the `name` property from nodes, and the `id` property from relationships). @@ -117,11 +115,13 @@ _In the `samplePath` with a length of `6` returned by `DIFFERENT RELATIONSHIPS`, However, if the relationship count is increased to `7`, `0` paths are returned. .Find paths with a length of 7 relationships +// tag::patterns_match_modes_different_relationships[] [source, cypher] ---- MATCH p = (:Location {name: 'Kneiphof'})--{7}() RETURN count(p) AS pathCount ---- +// end::patterns_match_modes_different_relationships[] .Result [role="queryresult",options="header,footer",cols="1*