From 62c81b9e8da567714632558e937ac701cd881724 Mon Sep 17 00:00:00 2001 From: Gemma Lamont Date: Fri, 25 Oct 2024 14:15:43 +0200 Subject: [PATCH 1/2] Allow for parameters in SHORTEST --- ...ions-additions-removals-compatibility.adoc | 20 +++++++++++++++++++ modules/ROOT/pages/patterns/reference.adoc | 4 ++-- .../ROOT/pages/patterns/shortest-paths.adoc | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc index f7691d071..1ead372b0 100644 --- a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc +++ b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc @@ -93,6 +93,26 @@ MATCH (n)-[r:REL]->(m) SET n = properties(r) | Feature | Details +a| +label:functionality[] +label:updated[] +[source, cypher, role=noheader] +---- +MATCH SHORTEST $param (:A)-[:R]->{0,10}(:B) +---- + +[source, cypher, role=noheader] +---- +MATCH p = ANY $param (:A)-[:R]->{0,10}(:B) +---- + +[source, cypher, role=noheader] +---- +MATCH SHORTEST $param GROUPS (:A)-[:R]->{0,10}(:B) +---- + +a| Introduced the allowance of parameters to the xref:patterns/shortest-paths.adoc[SHORTEST and ANY path patterns]. + a| label:functionality[] label:updated[] diff --git a/modules/ROOT/pages/patterns/reference.adoc b/modules/ROOT/pages/patterns/reference.adoc index 4ea43aaab..3f762c53f 100644 --- a/modules/ROOT/pages/patterns/reference.adoc +++ b/modules/ROOT/pages/patterns/reference.adoc @@ -1165,10 +1165,10 @@ anyPathSearch ::= "ANY" [ numberOfPaths ] [ pathOrPaths ] pathOrPaths ::= { "PATH" | "PATHS" } -numberOfPaths ::= unsignedDecimalInteger +numberOfPaths ::= unsignedDecimalInteger | parameter -numberOfGroups ::= unsignedDecimalInteger +numberOfGroups ::= unsignedDecimalInteger | parameter ---- [NOTE] diff --git a/modules/ROOT/pages/patterns/shortest-paths.adoc b/modules/ROOT/pages/patterns/shortest-paths.adoc index a177ffce3..51c7f4869 100644 --- a/modules/ROOT/pages/patterns/shortest-paths.adoc +++ b/modules/ROOT/pages/patterns/shortest-paths.adoc @@ -19,7 +19,7 @@ Use Cypher if: * You need to specify complex graph navigation via xref:patterns/variable-length-patterns.adoc#quantified-path-patterns[quantified path patterns]. * Creating a link:https://neo4j.com/docs/graph-data-science/current/management-ops/graph-creation/graph-project/[graph projection] takes too long. -* GDS is not available in your instance, or the size of the GDS projection is too large for your instance. +* GDS is not available in your instance, or the size of the GDS projection is too large for your instance. Use GDS if: @@ -64,7 +64,7 @@ CREATE (asc)-[:LINK {distance: 7.25}]->(cnm), (wof)-[:LINK {distance: 0.65}]->(wos) ---- -The paths matched by a xref:patterns/fixed-length-patterns.adoc#path-patterns[path pattern] can be restricted to only the shortest (by number of hops) by including the keyword `SHORTEST k`, where `k` is the number of paths to match. +The paths matched by a xref:patterns/fixed-length-patterns.adoc#path-patterns[path pattern] can be restricted to only the shortest (by number of hops) by including the keyword `SHORTEST k`, where `k` is the number of paths to match, and can be either an `INTEGER` literal or a parameter which resolves to an `INTEGER`. For example, the following example uses `SHORTEST 1` to return the length of the shortest path between `Worcester Shrub Hill` and `Bromsgrove`: .Query From a88cf194fd432f87214598f5d470103a077fb643 Mon Sep 17 00:00:00 2001 From: Gem Lamont <106068376+gem-neo4j@users.noreply.github.com> Date: Thu, 28 Nov 2024 15:30:50 +0100 Subject: [PATCH 2/2] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jens Pryce-Ã…klundh <112686610+JPryce-Aklundh@users.noreply.github.com> --- .../pages/deprecations-additions-removals-compatibility.adoc | 2 +- modules/ROOT/pages/patterns/shortest-paths.adoc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc index 1ead372b0..f644e763f 100644 --- a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc +++ b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc @@ -111,7 +111,7 @@ MATCH p = ANY $param (:A)-[:R]->{0,10}(:B) MATCH SHORTEST $param GROUPS (:A)-[:R]->{0,10}(:B) ---- -a| Introduced the allowance of parameters to the xref:patterns/shortest-paths.adoc[SHORTEST and ANY path patterns]. +a| Parameters can now be used in xref:patterns/shortest-paths.adoc[`SHORTEST` and `ANY` path patterns]. a| label:functionality[] diff --git a/modules/ROOT/pages/patterns/shortest-paths.adoc b/modules/ROOT/pages/patterns/shortest-paths.adoc index 51c7f4869..0e9e9bd14 100644 --- a/modules/ROOT/pages/patterns/shortest-paths.adoc +++ b/modules/ROOT/pages/patterns/shortest-paths.adoc @@ -64,7 +64,7 @@ CREATE (asc)-[:LINK {distance: 7.25}]->(cnm), (wof)-[:LINK {distance: 0.65}]->(wos) ---- -The paths matched by a xref:patterns/fixed-length-patterns.adoc#path-patterns[path pattern] can be restricted to only the shortest (by number of hops) by including the keyword `SHORTEST k`, where `k` is the number of paths to match, and can be either an `INTEGER` literal or a parameter which resolves to an `INTEGER`. +The paths matched by a xref:patterns/fixed-length-patterns.adoc#path-patterns[path pattern] can be restricted to only the shortest (by number of hops) by including the keyword `SHORTEST k`, where `k` is the number of paths to match, and can be either an `INTEGER` literal or, as of Neo4j 2025.01, a parameter which resolves to an `INTEGER`. For example, the following example uses `SHORTEST 1` to return the length of the shortest path between `Worcester Shrub Hill` and `Bromsgrove`: .Query