From 0a6fd917f1790a25163082c6d46d79bcdd1a10bb Mon Sep 17 00:00:00 2001 From: Richard Sill Date: Wed, 18 Dec 2024 11:35:26 +0100 Subject: [PATCH 1/5] tags for the FINISH clause --- modules/ROOT/pages/clauses/finish.adoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/ROOT/pages/clauses/finish.adoc b/modules/ROOT/pages/clauses/finish.adoc index b233b4896..a55dd9392 100644 --- a/modules/ROOT/pages/clauses/finish.adoc +++ b/modules/ROOT/pages/clauses/finish.adoc @@ -9,20 +9,24 @@ A query ending in `FINISH` — instead of `RETURN` — has no result but execute The following read query successfully executes but has no results: .Query +tag::clauses_finish_match[] [source, cypher] ---- MATCH (p:Person) FINISH ---- +end::clauses_finish_match[] The following query has no result but creates one node with the label `Person`: .Query +tag::clauses_finish_create[] [source, cypher] ---- CREATE (p:Person) FINISH ---- +end::clauses_finish_create[] It is equivalent to the following query: From f9594236afa768f9146620c4dbf013d42145cc45 Mon Sep 17 00:00:00 2001 From: Richard Sill Date: Wed, 18 Dec 2024 12:05:12 +0100 Subject: [PATCH 2/5] tags for the USE clause --- modules/ROOT/pages/clauses/finish.adoc | 2 +- modules/ROOT/pages/clauses/use.adoc | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/ROOT/pages/clauses/finish.adoc b/modules/ROOT/pages/clauses/finish.adoc index a55dd9392..816ae1665 100644 --- a/modules/ROOT/pages/clauses/finish.adoc +++ b/modules/ROOT/pages/clauses/finish.adoc @@ -3,7 +3,7 @@ [[query-finish]] = FINISH -A query ending in `FINISH` — instead of `RETURN` — has no result but executes all its side effects. +A query ending in `FINISH` -- instead of `RETURN` -- has no result but executes all its side effects. `FINISH` was introduced as part of Cypher's xref:appendix/gql-conformance/index.adoc[]. The following read query successfully executes but has no results: diff --git a/modules/ROOT/pages/clauses/use.adoc b/modules/ROOT/pages/clauses/use.adoc index 1d5643469..a6045f548 100644 --- a/modules/ROOT/pages/clauses/use.adoc +++ b/modules/ROOT/pages/clauses/use.adoc @@ -68,14 +68,16 @@ CREATE ALIAS `myComposite`.`myConstituent` FOR DATABASE `myDatabase`; [[query-use-examples-query-graph]] === Query a graph -In this example it is assumed that the DBMS contains a database named `myDatabase`: +This example assumes that the DBMS contains a database named `myDatabase`: .Query +tag::clauses_use[] [source, cypher] ---- USE myDatabase MATCH (n) RETURN n ---- +end::clauses_use[] [[query-use-examples-query-composite-database-constituent-graph]] === Query a composite database constituent graph @@ -83,11 +85,13 @@ MATCH (n) RETURN n In this example it is assumed that the DBMS contains a composite database named `myComposite`, which includes an alias named `myConstituent`: .Query +tag::clauses_use_composite[] [source, cypher] ---- USE myComposite.myConstituent MATCH (n) RETURN n ---- +end::clauses_use_composite[] [[query-use-examples-query-composite-database-constituent-graph-dynamically]] From 943cf62b8996aea6b84f2c04de40e514b7f9dca7 Mon Sep 17 00:00:00 2001 From: Richard Sill Date: Wed, 18 Dec 2024 16:09:52 +0100 Subject: [PATCH 3/5] tags for ORDER BY, SKIP and UNWIND --- modules/ROOT/pages/clauses/order-by.adoc | 8 ++++++++ modules/ROOT/pages/clauses/skip.adoc | 6 ++++++ modules/ROOT/pages/clauses/unwind.adoc | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/modules/ROOT/pages/clauses/order-by.adoc b/modules/ROOT/pages/clauses/order-by.adoc index feb5bb766..c33e49b01 100644 --- a/modules/ROOT/pages/clauses/order-by.adoc +++ b/modules/ROOT/pages/clauses/order-by.adoc @@ -40,12 +40,14 @@ CREATE `ORDER BY` is used to sort the output. .Query +tag::clauses_order_by[] [source, cypher] ---- MATCH (n) RETURN n.name, n.age ORDER BY n.name ---- +end::clauses_order_by[] The nodes are returned, sorted by their name. @@ -67,12 +69,14 @@ You can order by multiple properties by stating each variable in the `ORDER BY` Cypher will sort the result by the first variable listed, and for equals values, go to the next property in the `ORDER BY` clause, and so on. .Query +tag::clauses_order_by_multiple[] [source, cypher] ---- MATCH (n) RETURN n.name, n.age ORDER BY n.age, n.name ---- +end::clauses_order_by_multiple[] This returns the nodes, sorted first by their age, and then by their name. @@ -246,12 +250,14 @@ Read more about this capability in xref::indexes/search-performance-indexes/usin .Standalone use of `ORDER BY` +tag::clauses_order_by_standalone[] [source, cypher] ---- MATCH (n) ORDER BY n.name RETURN collect(n.name) AS names ---- +end::clauses_order_by_standalone[] .Result [role="queryresult",options="header,footer",cols="1* Date: Thu, 19 Dec 2024 10:06:39 +0100 Subject: [PATCH 4/5] tags for LIMIT and FOREACH --- modules/ROOT/pages/clauses/foreach.adoc | 2 ++ modules/ROOT/pages/clauses/limit.adoc | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/modules/ROOT/pages/clauses/foreach.adoc b/modules/ROOT/pages/clauses/foreach.adoc index b594ecace..1f792bfc0 100644 --- a/modules/ROOT/pages/clauses/foreach.adoc +++ b/modules/ROOT/pages/clauses/foreach.adoc @@ -36,12 +36,14 @@ CREATE This query will set the property `marked` to `true` on all nodes along a path. .Query +tag::clauses_foreach[] [source, cypher, indent=0] ---- MATCH p=(start)-[*]->(finish) WHERE start.name = 'A' AND finish.name = 'D' FOREACH (n IN nodes(p) | SET n.marked = true) ---- +end::clauses_foreach[] .Result [role="queryresult",options="footer",cols="1* Date: Fri, 20 Dec 2024 10:00:26 +0100 Subject: [PATCH 5/5] escaped tags, added tags for LOAD CSV --- modules/ROOT/pages/clauses/finish.adoc | 8 ++++---- modules/ROOT/pages/clauses/foreach.adoc | 4 ++-- modules/ROOT/pages/clauses/limit.adoc | 8 ++++---- modules/ROOT/pages/clauses/load-csv.adoc | 16 +++++++++++++++- modules/ROOT/pages/clauses/order-by.adoc | 16 ++++++++-------- modules/ROOT/pages/clauses/skip.adoc | 12 ++++++------ modules/ROOT/pages/clauses/unwind.adoc | 12 ++++++------ modules/ROOT/pages/clauses/use.adoc | 8 ++++---- 8 files changed, 49 insertions(+), 35 deletions(-) diff --git a/modules/ROOT/pages/clauses/finish.adoc b/modules/ROOT/pages/clauses/finish.adoc index 816ae1665..27813a216 100644 --- a/modules/ROOT/pages/clauses/finish.adoc +++ b/modules/ROOT/pages/clauses/finish.adoc @@ -9,24 +9,24 @@ A query ending in `FINISH` -- instead of `RETURN` -- has no result but executes The following read query successfully executes but has no results: .Query -tag::clauses_finish_match[] +// tag::clauses_finish_match[] [source, cypher] ---- MATCH (p:Person) FINISH ---- -end::clauses_finish_match[] +// end::clauses_finish_match[] The following query has no result but creates one node with the label `Person`: .Query -tag::clauses_finish_create[] +// tag::clauses_finish_create[] [source, cypher] ---- CREATE (p:Person) FINISH ---- -end::clauses_finish_create[] +// end::clauses_finish_create[] It is equivalent to the following query: diff --git a/modules/ROOT/pages/clauses/foreach.adoc b/modules/ROOT/pages/clauses/foreach.adoc index 1f792bfc0..b9678fb2e 100644 --- a/modules/ROOT/pages/clauses/foreach.adoc +++ b/modules/ROOT/pages/clauses/foreach.adoc @@ -36,14 +36,14 @@ CREATE This query will set the property `marked` to `true` on all nodes along a path. .Query -tag::clauses_foreach[] +// tag::clauses_foreach[] [source, cypher, indent=0] ---- MATCH p=(start)-[*]->(finish) WHERE start.name = 'A' AND finish.name = 'D' FOREACH (n IN nodes(p) | SET n.marked = true) ---- -end::clauses_foreach[] +// end::clauses_foreach[] .Result [role="queryresult",options="footer",cols="1*