diff --git a/modules/ROOT/content-nav.adoc b/modules/ROOT/content-nav.adoc index bdbda333e..4cf18d64e 100644 --- a/modules/ROOT/content-nav.adoc +++ b/modules/ROOT/content-nav.adoc @@ -12,32 +12,65 @@ * xref:clauses/index.adoc[] ** xref:clauses/clause-composition.adoc[] -** xref:clauses/call.adoc[] -** xref:clauses/create.adoc[] -** xref:clauses/delete.adoc[] -** xref:clauses/filter.adoc[] -** xref:clauses/finish.adoc[] -** xref:clauses/foreach.adoc[] -** xref:clauses/let.adoc[] -** xref:clauses/limit.adoc[] -** xref:clauses/load-csv.adoc[] -** xref:clauses/match.adoc[] -** xref:clauses/merge.adoc[] -** xref:clauses/optional-match.adoc[] -** xref:clauses/order-by.adoc[] -** xref:clauses/remove.adoc[] -** xref:clauses/return.adoc[] -** xref:clauses/set.adoc[] -** xref:clauses/listing-functions.adoc[] -** xref:clauses/listing-procedures.adoc[] -** xref:clauses/listing-settings.adoc[] -** xref:clauses/transaction-clauses.adoc#query-listing-transactions[SHOW TRANSACTIONS] -** xref:clauses/skip.adoc[] -** xref:clauses/transaction-clauses.adoc#query-terminate-transactions[TERMINATE TRANSACTIONS] -** xref:clauses/unwind.adoc[] -** xref:clauses/use.adoc[] -** xref:clauses/where.adoc[] -** xref:clauses/with.adoc[] + +** xref:clauses/read.adoc[] +*** xref:clauses/filter.adoc[] +*** xref:clauses/match.adoc[] +*** xref:clauses/optional-match.adoc[] + +** xref:clauses/projection.adoc[] +*** xref:clauses/finish.adoc[] +*** xref:clauses/let.adoc[] +*** xref:clauses/return.adoc[] +*** xref:clauses/unwind.adoc[] +*** xref:clauses/with.adoc[] + +** xref:clauses/projection-read-subclauses.adoc[] +*** xref:clauses/limit.adoc[] +*** xref:clauses/order-by.adoc[] +*** xref:clauses/skip.adoc[] +*** xref:clauses/where.adoc[] + +** xref:clauses/write.adoc[] +*** xref:clauses/create.adoc[] +*** xref:clauses/delete.adoc[] +*** xref::clauses/delete.adoc#delete-all-nodes-and-relationships[DETACH DELETE] +*** xref:clauses/foreach.adoc[] +*** xref:clauses/remove.adoc[] +*** xref:clauses/set.adoc[] + +** xref:clauses/read-write.adoc[] +*** xref:clauses/merge.adoc[] + +** xref:clauses/invocation.adoc[] +*** xref:clauses/call.adoc[CALL (procedure)] +*** xref:clauses/call.adoc#optional-call[OPTIONAL CALL (procedure)] +*** xref:subqueries/call-subquery.adoc[CALL (subquery)] +*** xref:subqueries/call-subquery.adoc#optional-call[OPTIONAL CALL (subquery)] +*** xref:subqueries/subqueries-in-transactions.adoc[] + +** xref:clauses/import.adoc[] +*** xref:clauses/load-csv.adoc[] + +** xref:clauses/graph-selection.adoc[] +*** xref:clauses/use.adoc[] + +** xref:clauses/schema.adoc[] +*** xref:constraints/managing-constraints.adoc#create-constraint[CREATE CONSTRAINT] +*** xref:constraints/managing-constraints.adoc#list-constraints[SHOW CONSTRAINTS] +*** xref:constraints/managing-constraints.adoc#drop-constraint[DROP CONSTRAINTS] +*** xref:indexes/search-performance-indexes/managing-indexes.adoc#create-range-index[CREATE INDEX] +*** xref:indexes/search-performance-indexes/managing-indexes.adoc#list-indexes[SHOW INDEXES] +*** xref:indexes/search-performance-indexes/managing-indexes.adoc#drop-indexes[DROP INDEX] + + +** xref:clauses/metadata.adoc[] +*** xref:clauses/listing-functions.adoc[] +*** xref:clauses/listing-procedures.adoc[] +*** xref:clauses/listing-settings.adoc[] +*** xref:clauses/transaction-clauses.adoc#query-listing-transactions[SHOW TRANSACTIONS] +*** xref:clauses/transaction-clauses.adoc#query-terminate-transactions[TERMINATE TRANSACTIONS] + * xref:subqueries/index.adoc[] ** xref:subqueries/call-subquery.adoc[] diff --git a/modules/ROOT/pages/appendix/gql-conformance/index.adoc b/modules/ROOT/pages/appendix/gql-conformance/index.adoc index f6c6d653b..ca98717e4 100644 --- a/modules/ROOT/pages/appendix/gql-conformance/index.adoc +++ b/modules/ROOT/pages/appendix/gql-conformance/index.adoc @@ -15,7 +15,7 @@ For example, the following query is valid in both languages: [source, cypher] ---- MATCH (a:Actor)-[:ACTED_IN]->(m:Movie) -WHERE a.name = 'Tom Hanks' + WHERE a.name = 'Tom Hanks' RETURN m.title ---- diff --git a/modules/ROOT/pages/appendix/tutorials/advanced-query-tuning.adoc b/modules/ROOT/pages/appendix/tutorials/advanced-query-tuning.adoc index 5d5816465..fc03a21a5 100644 --- a/modules/ROOT/pages/appendix/tutorials/advanced-query-tuning.adoc +++ b/modules/ROOT/pages/appendix/tutorials/advanced-query-tuning.adoc @@ -625,7 +625,7 @@ In this example you want to write a query to find persons with the name 'Tom' th [source, cypher, indent=0] ---- MATCH (p:Person)-[:ACTED_IN]->(m:Movie) -WHERE p.name STARTS WITH 'Tom' + WHERE p.name STARTS WITH 'Tom' RETURN p.name AS name, count(m) AS count @@ -656,7 +656,7 @@ We can also see that the `OrderedAggregation` has no `DB Hits`, which means it d ---- PROFILE MATCH (p:Person)-[:ACTED_IN]->(m:Movie) -WHERE p.name STARTS WITH 'Tom' + WHERE p.name STARTS WITH 'Tom' RETURN p.name AS name, count(m) AS count @@ -808,11 +808,10 @@ Now consider the following refinement to the query: ---- PROFILE MATCH (p:Person)-[:ACTED_IN]->(m:Movie) -WHERE p.name STARTS WITH 'Tom' -RETURN - p.name AS name, - count(m) AS count -ORDER BY name + WHERE p.name STARTS WITH 'Tom' +RETURN p.name AS name, + count(m) AS count + ORDER BY name ---- .Query Plan diff --git a/modules/ROOT/pages/appendix/tutorials/shortestpath-planning.adoc b/modules/ROOT/pages/appendix/tutorials/shortestpath-planning.adoc index 40df8bc60..620b4d8f5 100644 --- a/modules/ROOT/pages/appendix/tutorials/shortestpath-planning.adoc +++ b/modules/ROOT/pages/appendix/tutorials/shortestpath-planning.adoc @@ -70,7 +70,7 @@ MATCH (KevinB:Person {name: 'Kevin Bacon'}), (Al:Person {name: 'Al Pacino'}), p = shortestPath((KevinB)-[:ACTED_IN*]-(Al)) -WHERE all(r IN relationships(p) WHERE r.role IS NOT NULL) + WHERE all(r IN relationships(p) WHERE r.role IS NOT NULL) RETURN p ---- @@ -145,7 +145,7 @@ MATCH (KevinB:Person {name: 'Kevin Bacon'}), (Al:Person {name: 'Al Pacino'}), p = shortestPath((KevinB)-[*]-(Al)) -WHERE length(p) > 1 + WHERE length(p) > 1 RETURN p ---- @@ -246,7 +246,7 @@ MATCH (Al:Person {name: 'Al Pacino'}), p = shortestPath((KevinB)-[*]-(Al)) WITH p -WHERE length(p) > 1 + WHERE length(p) > 1 RETURN p ---- diff --git a/modules/ROOT/pages/clauses/call.adoc b/modules/ROOT/pages/clauses/call.adoc index 4431598e6..bafe89b6b 100644 --- a/modules/ROOT/pages/clauses/call.adoc +++ b/modules/ROOT/pages/clauses/call.adoc @@ -212,7 +212,7 @@ This requires knowing the names of the arguments within a procedure's signature, [source, cypher] ---- SHOW PROCEDURES YIELD name, signature -WHERE name = 'db.propertyKeys' + WHERE name = 'db.propertyKeys' RETURN signature ---- @@ -235,7 +235,7 @@ In the below example, `propertyKey` is aliased as `prop` and then used later in ---- CALL db.propertyKeys() YIELD propertyKey AS prop MATCH (n) -WHERE n[prop] IS NOT NULL + WHERE n[prop] IS NOT NULL RETURN prop, count(n) AS numNodes ---- diff --git a/modules/ROOT/pages/clauses/filter.adoc b/modules/ROOT/pages/clauses/filter.adoc index 09f6511db..feb4709f4 100644 --- a/modules/ROOT/pages/clauses/filter.adoc +++ b/modules/ROOT/pages/clauses/filter.adoc @@ -147,7 +147,7 @@ This `OPTIONAL MATCH` example highlights the differences between the `WHERE` sub ---- UNWIND [32,37,40] AS ageValue OPTIONAL MATCH (p:Person) -WHERE p.age = ageValue + WHERE p.age = ageValue RETURN p.name AS name, p.age AS age ---- @@ -241,7 +241,7 @@ For example, the following two queries are equivalent: ---- UNWIND [1, 2, 3, 4, 5, 6] AS x WITH x -WHERE x > 2 + WHERE x > 2 RETURN x ---- @@ -275,7 +275,7 @@ Id,Name,Location,Email,BusinessType ---- LOAD CSV WITH HEADERS FROM 'file:///companies.csv' AS row WITH row -WHERE row.Id IS NOT NULL + WHERE row.Id IS NOT NULL MERGE (c:Company {id: row.Id}) ---- diff --git a/modules/ROOT/pages/clauses/foreach.adoc b/modules/ROOT/pages/clauses/foreach.adoc index 2132954e6..4a052dafe 100644 --- a/modules/ROOT/pages/clauses/foreach.adoc +++ b/modules/ROOT/pages/clauses/foreach.adoc @@ -40,7 +40,7 @@ This query sets the property `marked` to `true` on all nodes along a path. [source, cypher, indent=0] ---- MATCH p=(start)-[*]->(finish) -WHERE start.name = 'A' AND finish.name = 'D' + WHERE start.name = 'A' AND finish.name = 'D' FOREACH (n IN nodes(p) | SET n.marked = true) ---- // end::clauses_foreach_node[] diff --git a/modules/ROOT/pages/clauses/graph-selection.adoc b/modules/ROOT/pages/clauses/graph-selection.adoc new file mode 100644 index 000000000..b56dec8db --- /dev/null +++ b/modules/ROOT/pages/clauses/graph-selection.adoc @@ -0,0 +1,7 @@ += Graph selection clauses +:description: Information about Cypher's graph selection clauses. + +Cypher's contains one graph selection clause -- `USE` -- which allows you to select which graph a query, or query part, is executed against. +For more information, see: + +* xref:clauses/use.adoc[`USE`] \ No newline at end of file diff --git a/modules/ROOT/pages/clauses/import.adoc b/modules/ROOT/pages/clauses/import.adoc new file mode 100644 index 000000000..8dd1777ac --- /dev/null +++ b/modules/ROOT/pages/clauses/import.adoc @@ -0,0 +1,12 @@ += Import clauses +:description: Information about Cypher's import clauses. + +Cypher's contains one clause to import data -- `LOAD CSV` -- which allows you to load csv into a graph. +For more information, see: + +* xref:clauses/load-csv.adoc[`LOAD CSV`] + +[NOTE] +There are several ways to import data into your Neo4j instance. +For a comparison of all available methods, see the link:https://neo4j.com/docs/getting-started/data-import/#_methods_comparison[Getting Started Guide -> Import data into Neo4j -> Methods comparison]. + diff --git a/modules/ROOT/pages/clauses/index.adoc b/modules/ROOT/pages/clauses/index.adoc index a7cdfb28b..c5b21bc75 100644 --- a/modules/ROOT/pages/clauses/index.adoc +++ b/modules/ROOT/pages/clauses/index.adoc @@ -3,291 +3,26 @@ [[query-clause]] = Clauses -This section contains information on all the clauses in the Cypher query language. +This chapter contains information on all the clauses and subclauses in the Cypher query language (with the exception of the database administration commands, which are documented in the link:{neo4j-docs-base-uri}/operations-manual/current/database-administration/[Operations Manual -> Database administration], link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/[Authentication and authorization], and link:{neo4j-docs-base-uri}/operations-manual/current/clustering/[Clustering]). -[[reading-clauses]] -== Reading clauses +* xref:clauses/clause-composition.adoc[]: describes the semantics of Cypher when composing read and write queries. -These comprise clauses that read data from the database. +* xref:clauses/read.adoc[]: information about xref:clauses/filter.adoc[`FILTER`], xref:clauses/match.adoc[`MATCH`], and xref:clauses/optional-match.adoc[`OPTIONAL MATCH`]. -The flow of data within a Cypher query is an unordered sequence of maps with key-value pairs -- a set of possible bindings between the variables in the query and values derived from the database. -This set is refined and augmented by subsequent parts of the query. +* xref:clauses/projection.adoc[]: information about xref:clauses/finish.adoc[`FINISH`], xref:clauses/let.adoc[`LET`],xref:clauses/return.adoc[`RETURN`], xref:clauses/unwind.adoc[`UNWIND`], and xref:clauses/with.adoc[`WITH`]. -[options="header"] -|=== -| Clause | Description +* xref:clauses/projection-read-subclauses.adoc[]: information about xref:clauses/limit.adoc[`LIMIT`], xref:clauses/order-by[`ORDER BY`], xref:clauses/skip.adoc[`SKIP`/ `OFFSET`], and xref:clauses/where.adoc[`WHERE`]. +* xref:clauses/write.adoc[]: information about xref::clauses/create.adoc[`CREATE`], xref::clauses/delete.adoc[`DELETE`], xref::clauses/delete.adoc#delete-all-nodes-and-relationships[`DETACH DELETE`], xref::clauses/foreach.adoc[`FOREACH`], xref::clauses/set.adoc[`SET`], and xref::clauses/remove.adoc[`REMOVE`]. -m| xref::clauses/filter.adoc[FILTER] -| Adds filters to queries. -label:new[Introduced in Neo4j 2025.06] +* xref:clauses/read-write.adoc[]: information about xref:clauses/merge.adoc[`MERGE`]. -m| xref::clauses/match.adoc[MATCH] -| Specify the patterns to search for in the database. +* xref:clauses/invocation.adoc[]: information about xref:clauses/call.adoc[`CALL` (procedure)], xref:subqueries/call-subquery.adoc[`CALL` (subquery)], xref:subqueries/call-subquery.adoc#optional-call[`OPTIONAL CALL` (subquery)], and xref:subqueries/subqueries-in-transactions.adoc[`CALL` subqueries in transactions]. -m| xref::clauses/optional-match.adoc[OPTIONAL MATCH] -| Specify the patterns to search for in the database while using `nulls` for missing parts of the pattern. +* xref:clauses/import.adoc[]: information about xref:clauses/load-csv.adoc[`LOAD CSV`]. -|=== +* xref:clauses/graph-selection.adoc[]: information about xref:clauses/use.adoc[`USE`]. -[[projecting-clauses]] -== Projecting clauses +* xref:clauses/schema.adoc[]: information about xref:constraints/managing-constraints.adoc#create-constraint[`CREATE CONSTRAINT`], xref:constraints/managing-constraints.adoc#list-constraints[`SHOW CONSTRAINTS`], xref:constraints/managing-constraints.adoc#drop-constraint[`DROP CONSTRAINTS`], xref:indexes/search-performance-indexes/managing-indexes.adoc#create-range-index[`CREATE INDEX`], xref:indexes/search-performance-indexes/managing-indexes.adoc#list-indexes[`SHOW INDEXES`], and xref:indexes/search-performance-indexes/managing-indexes.adoc#drop-indexes[`DROP INDEX`]. -These comprise clauses that define which expressions to return in the result set. -The returned expressions may all be aliased using `AS`. - -[options="header"] -|=== -| Clause | Description - -m| xref::clauses/finish.adoc[FINISH] -| Defines a query to have no result. - -m| xref::clauses/let.adoc[LET] -| Binds values to variables. -label:new[Introduced in Neo4j 2025.06] - -m| xref::clauses/return.adoc[RETURN ... [AS]] -| Defines what to include in the query result set. - -m| xref::clauses/unwind.adoc[UNWIND ... [AS]] -| Expands a list into a sequence of rows. - -m| xref::clauses/with.adoc[WITH ... [AS]] -| Allows query parts to be chained together, piping the results from one to be used as starting points or criteria in the next. - -|=== - -[[reading-sub-clauses]] -== Reading sub-clauses - -These comprise sub-clauses that must operate as part of reading clauses. - -[options="header"] -|=== -| Sub-clause | Description - -m| xref::clauses/where.adoc[WHERE] -| Adds constraints to the patterns in a `MATCH` or `OPTIONAL MATCH` clause or filters the results of a `WITH` clause. - -m| xref::clauses/order-by.adoc[ORDER BY [ASC[ENDING\] \| DESC[ENDING\]\]] -| A sub-clause following `RETURN` or `WITH`, specifying that the output should be sorted in either ascending (the default) or descending order. - -m| xref::clauses/skip.adoc[SKIP] / xref::clauses/skip.adoc#offset-synonym[`OFFSET`] -| Defines from which row to start including the rows in the output. - -m| xref::clauses/limit.adoc[LIMIT] -| Constrains the number of rows in the output. - -|=== - -[[writing-clauses]] -== Writing clauses - -These comprise clauses that write the data to the database. - -[options="header"] -|=== -| Clause | Description - -m| xref::clauses/create.adoc[CREATE] -| Create nodes and relationships. - -m| xref::clauses/delete.adoc[DELETE] -a| -Delete nodes, relationships or paths. -Any node to be deleted must also have all associated relationships explicitly deleted. - -m| xref::clauses/delete.adoc[DETACH DELETE] -a| -Delete a node or set of nodes. -All associated relationships will automatically be deleted. - -m| xref::clauses/set.adoc[SET] -| Update labels on nodes and properties on nodes and relationships. - -m| xref::clauses/remove.adoc[REMOVE] -| Remove properties and labels from nodes and relationships. - -m| xref::clauses/foreach.adoc[FOREACH] -| Update data within a list, whether components of a path, or the result of aggregation. - -|=== - -[[reading-writing-clauses]] -== Reading/Writing clauses - -These comprise clauses that both read data from and write data to the database. - -[options="header"] -|=== -| Clause | Description - -m| xref::clauses/merge.adoc[MERGE] -| Ensures that a pattern exists in the graph. Either the pattern already exists, or it needs to be created. - -m| --- xref::clauses/merge.adoc#query-merge-on-create-on-match[ON CREATE] -| Used in conjunction with `MERGE`, this write sub-clause specifies the actions to take if the pattern needs to be created. - -m| --- xref::clauses/merge.adoc#query-merge-on-create-on-match[ON MATCH] -| Used in conjunction with `MERGE`, this write sub-clause specifies the actions to take if the pattern already exists. - -m| xref::clauses/call.adoc[CALL ... [YIELD ... ]] -| Invokes a procedure deployed in the database and return any results. - -|=== - -[[subquery-clauses]] -== Subquery clauses - -[options="header"] -|=== -|Clause |Description - -m| xref::subqueries/call-subquery.adoc[CALL { ... }] -| Evaluates a subquery, typically used for post-union processing or aggregations. - -m| xref::subqueries/subqueries-in-transactions.adoc[CALL { ... } IN TRANSACTIONS] -a| -Evaluates a subquery in separate transactions. -Typically used when modifying or importing large amounts of data. - -|=== - -[[set-operations-clauses]] -== Set operations - -[options="header"] -|=== -|Clause |Description - -m| xref::queries/composed-queries/combined-queries.adoc[UNION] -a| -Combines the result of multiple queries into a single result set. -Duplicates are removed. - -m| xref::queries/composed-queries/combined-queries.adoc[UNION ALL] -a| -Combines the result of multiple queries into a single result set. -Duplicates are retained. - -|=== - -[[multiple-graphs-clauses]] -== Multiple graphs - -[options="header"] -|=== -| Clause | Description - -m| xref::clauses/use.adoc[USE] -| Determines which graph a query, or query part, is executed against. - -|=== - -[[importing-clauses]] -== Importing data - -[options="header"] -|=== -| Clause | Description - -m| xref::clauses/load-csv.adoc[LOAD CSV] -| Use when importing data from CSV files. - -m| xref::subqueries/subqueries-in-transactions.adoc[CALL { ... } IN TRANSACTIONS] -| This clause may be used to prevent an out-of-memory error from occurring when importing large amounts of data using `LOAD CSV`. - -|=== - -[[listing-functions-and-procedures]] -== Listing functions and procedures -[options="header"] -|=== -| Clause | Description - -m| xref::clauses/listing-functions.adoc[SHOW FUNCTIONS] -| List the available functions. - -m| xref::clauses/listing-procedures.adoc[SHOW PROCEDURES] -| List the available procedures. - -|=== - -[[configuration-commands]] -== Configuration Commands - -[options="header"] -|=== -| Clause | Description - -m| xref:clauses/listing-settings.adoc[SHOW SETTINGS] -| List configuration settings. - -|=== - -[[transaction-commands]] -== Transaction Commands - -[options="header"] -|=== -| Clause | Description - -m| xref:clauses/transaction-clauses.adoc#query-listing-transactions[SHOW TRANSACTIONS] -| List the available transactions. - -m| xref:clauses/transaction-clauses.adoc#query-terminate-transactions[TERMINATE TRANSACTIONS] -| Terminate transactions by their IDs. - -|=== - - -[[reading-hints]] -== Reading hints - -These comprise clauses used to specify planner hints when tuning a query. -More details regarding the usage of these -- and query tuning in general -- can be found in xref::indexes/search-performance-indexes/index-hints.adoc[Planner hints and the USING keyword]. - -[options="header"] -|=== -| Hint | Description - -m| xref::indexes/search-performance-indexes/index-hints.adoc#query-using-index-hint[USING INDEX] -| Index hints are used to specify which index, if any, the planner should use as a starting point. - -m| xref::indexes/search-performance-indexes/index-hints.adoc#query-using-index-hint[USING INDEX SEEK] -| Index seek hint instructs the planner to use an index seek for this clause. - -m| xref::indexes/search-performance-indexes/index-hints.adoc#query-using-scan-hint[USING SCAN] -| Scan hints are used to force the planner to do a label scan (followed by a filtering operation) instead of using an index. - -m| xref::indexes/search-performance-indexes/index-hints.adoc#query-using-join-hint[USING JOIN] -| Join hints are used to enforce a join operation at specified points. - -|=== - -[[index-and-constraint-clauses]] -== Index and constraint clauses - -These comprise clauses to create, show, and drop indexes and constraints. - -[options="header"] -|=== -| Clause | Description - -m| xref:indexes/search-performance-indexes/managing-indexes.adoc#indexes-syntax[CREATE \| SHOW \| DROP INDEX] -| Create, show or drop an index. - -m| xref::constraints/syntax.adoc[CREATE \| SHOW \| DROP CONSTRAINT] -| Create, show or drop a constraint. -|=== - -[[administration-clauses]] -== Administration clauses - -Cypher includes commands to manage databases, aliases, servers, and role-based access control. -To learn more about each of these, see: - -* link:{neo4j-docs-base-uri}/operations-manual/current/database-administration[Operations Manual -> Database administration] -* link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/[Operations Manual -> Authentication and authorization] -* link:{neo4j-docs-base-uri}/operations-manual/current/clustering/[Operations Manual -> Clustering] +* xref:clauses/metadata.adoc[]: information about xref:clauses/listing-functions.adoc[`SHOW FUNCTIONS`], xref:clauses/listing-procedures.adoc[`SHOW PROCEDURES`], xref:clauses/listing-settings.adoc[`SHOW SETTINGS`], xref:clauses/transaction-clauses.adoc#query-listing-transactions[`SHOW TRANSACTIONS`], and xref:clauses/transaction-clauses.adoc#query-terminate-transactions[`TERMINATE TRANSACTIONS`]. diff --git a/modules/ROOT/pages/clauses/invocation.adoc b/modules/ROOT/pages/clauses/invocation.adoc new file mode 100644 index 000000000..f54388153 --- /dev/null +++ b/modules/ROOT/pages/clauses/invocation.adoc @@ -0,0 +1,11 @@ += Invocation clauses +:description: Information about Cypher's invocation clauses. + +Cypher’s `CALL` clause is used to invoke either procedures or subqueries, with optional handling of `null` results, and supports subqueries within transactions. +For more information, see: + +* xref:clauses/call.adoc[`CALL` (procedure)] +* xref:clauses/call.adoc#optional-call[`OPTIONAL CALL` (procedure)] +* xref:subqueries/call-subquery.adoc[`CALL` (subquery)] +* xref:subqueries/call-subquery.adoc#optional-call[`OPTIONAL CALL` (subquery)] +* xref:subqueries/subqueries-in-transactions.adoc[`CALL` subqueries in transactions] diff --git a/modules/ROOT/pages/clauses/let.adoc b/modules/ROOT/pages/clauses/let.adoc index ad7b313ca..02006df2d 100644 --- a/modules/ROOT/pages/clauses/let.adoc +++ b/modules/ROOT/pages/clauses/let.adoc @@ -204,7 +204,7 @@ LET discountCategory = CASE ELSE 'Budget' END RETURN p.name AS product, p.price AS price, isAffordable, discountCategory -ORDER BY price + ORDER BY price ---- // end::clauses_let_chain_expressions[] @@ -236,7 +236,7 @@ WITH p, isExpensive, isAffordable, ELSE 'Budget' END AS discountCategory RETURN p.name AS product, p.price AS price, isAffordable, discountCategory -ORDER BY price + ORDER BY price ---- ===== @@ -318,7 +318,7 @@ LET fullname = c.firstName + ' ' + c.lastName, effectivePrice = p.price * (1 - c.discount) LET message = fullname + " bought " + p.name + " for $" + effectivePrice + " after a " + (c.discount * 100) + "% discount" RETURN b.date AS date, message, s.email AS toSupplier -ORDER BY date + ORDER BY date ---- .Result @@ -379,7 +379,7 @@ LET message = { year: bought.date.year } RETURN message, customer.email AS toCustomer, customerRevenue -ORDER BY amount + ORDER BY amount ---- .Result diff --git a/modules/ROOT/pages/clauses/limit.adoc b/modules/ROOT/pages/clauses/limit.adoc index a75db6b56..ab3f87106 100644 --- a/modules/ROOT/pages/clauses/limit.adoc +++ b/modules/ROOT/pages/clauses/limit.adoc @@ -48,8 +48,8 @@ To return a limited subset of the rows, use this syntax: ---- MATCH (n) RETURN n.name -ORDER BY n.name -LIMIT 3 + ORDER BY n.name + LIMIT 3 ---- Limit to 3 rows by the example query. @@ -76,8 +76,8 @@ d|Rows: 3 ---- MATCH (n) RETURN n.name -ORDER BY n.name -LIMIT 1 + toInteger(3 * rand()) + ORDER BY n.name + LIMIT 1 + toInteger(3 * rand()) ---- Limit 1 row plus randomly 0, 1, or 2. @@ -105,7 +105,7 @@ The use of `LIMIT` in a query will not stop side effects, like `CREATE`, `DELETE ---- CREATE (n) RETURN n -LIMIT 0 + LIMIT 0 ---- This query returns nothing, but creates one node: @@ -124,7 +124,7 @@ Nodes created: 1 MATCH (n {name: 'A'}) SET n.age = 60 RETURN n -LIMIT 0 + LIMIT 0 ---- This query returns nothing, but writes one property: @@ -143,7 +143,9 @@ If we want to limit the number of updates we can split the query using the `WITH [source, cypher] ---- MATCH (n) -WITH n ORDER BY n.name LIMIT 1 +WITH n + ORDER BY n.name + LIMIT 1 SET n.locked = true RETURN n ---- diff --git a/modules/ROOT/pages/clauses/listing-functions.adoc b/modules/ROOT/pages/clauses/listing-functions.adoc index 59ce2a0e9..ea4bfddf2 100644 --- a/modules/ROOT/pages/clauses/listing-functions.adoc +++ b/modules/ROOT/pages/clauses/listing-functions.adoc @@ -246,7 +246,7 @@ For example, getting the name of all built-in functions starting with the letter [source, cypher] ---- SHOW BUILT IN FUNCTIONS YIELD name, isBuiltIn -WHERE name STARTS WITH 'a' + WHERE name STARTS WITH 'a' ---- .Result diff --git a/modules/ROOT/pages/clauses/listing-procedures.adoc b/modules/ROOT/pages/clauses/listing-procedures.adoc index 60f0cfd8c..3ce17fd95 100644 --- a/modules/ROOT/pages/clauses/listing-procedures.adoc +++ b/modules/ROOT/pages/clauses/listing-procedures.adoc @@ -257,7 +257,7 @@ For example, returning the names of all `admin` procedures: [source, cypher, role=test-result-skip] ---- SHOW PROCEDURES YIELD name, admin -WHERE admin + WHERE admin ---- .Result diff --git a/modules/ROOT/pages/clauses/listing-settings.adoc b/modules/ROOT/pages/clauses/listing-settings.adoc index c8537c296..8bb921929 100644 --- a/modules/ROOT/pages/clauses/listing-settings.adoc +++ b/modules/ROOT/pages/clauses/listing-settings.adoc @@ -186,9 +186,9 @@ For example, the following query returns the name, value, and description of the [source, cypher] ---- SHOW SETTINGS YIELD name, value, description -WHERE name STARTS WITH 'server' + WHERE name STARTS WITH 'server' RETURN name, value, description -LIMIT 3 + LIMIT 3 ---- .Result diff --git a/modules/ROOT/pages/clauses/load-csv.adoc b/modules/ROOT/pages/clauses/load-csv.adoc index dd75bd942..6cbd95729 100644 --- a/modules/ROOT/pages/clauses/load-csv.adoc +++ b/modules/ROOT/pages/clauses/load-csv.adoc @@ -526,7 +526,7 @@ RETURN p.name AS name, p.tmdbId AS tmdbId, p.born AS born -LIMIT 5 + LIMIT 5 ---- .Result @@ -637,7 +637,7 @@ RETURN m.imdbId AS imdbId, m.languages AS languages, m.genres AS genres -LIMIT 5 + LIMIT 5 ---- .Result @@ -1000,7 +1000,7 @@ RETURN count(*); // Check first 5 line-sample with header-mapping LOAD CSV WITH HEADERS FROM 'https://data.neo4j.com/importing-cypher/persons.csv' AS line RETURN line.person_tmdbId, line.name -LIMIT 5; + LIMIT 5 ---- .Result diff --git a/modules/ROOT/pages/clauses/match.adoc b/modules/ROOT/pages/clauses/match.adoc index 474d57da3..6b921da30 100644 --- a/modules/ROOT/pages/clauses/match.adoc +++ b/modules/ROOT/pages/clauses/match.adoc @@ -321,7 +321,7 @@ RETURN movie.title AS movieTitle, director.name AS director [[where-predicates]] == MATCH with WHERE predicates -The `MATCH` clause is often paired with a `WHERE` sub-clause, which adds predicates to refine the patterns, making them more specific. +The `MATCH` clause is often paired with a `WHERE` subclause, which adds predicates to refine the patterns, making them more specific. These predicates are part of the pattern itself, not just filters applied after matching. Thus, always place the `WHERE` clause with its corresponding `MATCH` clause. @@ -329,7 +329,7 @@ Thus, always place the `WHERE` clause with its corresponding `MATCH` clause. [source, cypher] ---- MATCH (charlie:Person)-[:ACTED_IN]->(movie:Movie) -WHERE charlie.name = 'Charlie Sheen' + WHERE charlie.name = 'Charlie Sheen' RETURN movie.title AS movieTitle ---- @@ -345,7 +345,7 @@ RETURN movie.title AS movieTitle [source, cypher] ---- MATCH (martin:Person)-[:ACTED_IN]->(movie:Movie) -WHERE martin.name = 'Martin Sheen' AND NOT EXISTS { + WHERE martin.name = 'Martin Sheen' AND NOT EXISTS { MATCH (movie)<-[:DIRECTED]-(director:Person {name: 'Oliver Stone'}) } RETURN movie.title AS movieTitle @@ -382,7 +382,7 @@ The `MATCH` clause can be used with parameters. [source, cypher] ---- MATCH (:Movie {title: $movieTitle})<-[r:ACTED_IN]-(p:Person) -WHERE r.role CONTAINS $actorRole + WHERE r.role CONTAINS $actorRole RETURN p.name AS actor, r.role AS role ---- @@ -433,7 +433,7 @@ RETURN path [source, cypher] ---- MATCH path = (:Person)-[:ACTED_IN]->(movie:Movie)<-[:DIRECTED]-(:Person) -WHERE movie.title = 'Wall Street' + WHERE movie.title = 'Wall Street' RETURN path ---- @@ -485,8 +485,8 @@ If a variable is neither implicitly nor explicitly carried over to its following ---- MATCH (actors:Person)-[:ACTED_IN]->(movies:Movie) // <1> WITH actors, count(movies) AS movieCount // <2> -ORDER BY movieCount DESC -LIMIT 1 // <3> + ORDER BY movieCount DESC + LIMIT 1 // <3> MATCH (actors)-[:ACTED_IN]->(movies) // <4> RETURN actors.name AS actor, movieCount, collect(movies.title) AS movies ---- diff --git a/modules/ROOT/pages/clauses/metadata.adoc b/modules/ROOT/pages/clauses/metadata.adoc new file mode 100644 index 000000000..11e9f1880 --- /dev/null +++ b/modules/ROOT/pages/clauses/metadata.adoc @@ -0,0 +1,12 @@ += Metadata clauses +:description: Information about Cypher's metadata clauses. + +Cypher's metadata clauses provide information about the available procedures, functions, configuration, and active transactions in a database, with `TERMINATE TRANSACTIONS` also allowing for the termination of transactions. + +The following clauses are included in this category: + +* xref:clauses/listing-functions.adoc[`SHOW FUNCTIONS`] +* xref:clauses/listing-procedures.adoc[`SHOW PROCEDURES`] +* xref:clauses/listing-settings.adoc[`SHOW SETTINGS`] +* xref:clauses/transaction-clauses.adoc#query-listing-transactions[`SHOW TRANSACTIONS`] +* xref:clauses/transaction-clauses.adoc#query-terminate-transactions[`TERMINATE TRANSACTIONS`] \ No newline at end of file diff --git a/modules/ROOT/pages/clauses/order-by.adoc b/modules/ROOT/pages/clauses/order-by.adoc index a5e4a78a4..b6ab6f7f3 100644 --- a/modules/ROOT/pages/clauses/order-by.adoc +++ b/modules/ROOT/pages/clauses/order-by.adoc @@ -1,10 +1,10 @@ -:description: `ORDER BY` is a sub-clause following `RETURN` or `WITH`, and it specifies that the output should be sorted and how. +:description: `ORDER BY` is a subclause following `RETURN` or `WITH`, and it specifies that the output should be sorted and how. [[query-order]] = ORDER BY -`ORDER BY` specifies how the output of a clause should be sorted. -It be used as a sub-clause following `RETURN` or `WITH`. +`ORDER BY` is a subclause which specifies the order in which the output of a xref:clauses/return.adoc[`RETURN`] or xref:clauses/with.adoc[`WITH`] clause. +As of Neo4j 5.24, it can also be used as a standalone clause, either on its own or in combination with `SKIP`/`OFFSET` or `LIMIT`. `ORDER BY` relies on comparisons to sort the output, see xref:values-and-types/ordering-equality-comparison.adoc[Ordering and comparison of values]. You can sort on many different values, e.g. node/relationship properties, the node/relationship ids, or on most expressions. @@ -44,7 +44,7 @@ CREATE ---- MATCH (n) RETURN n.name, n.age -ORDER BY n.name + ORDER BY n.name ---- // end::clauses_order_by[] @@ -73,7 +73,7 @@ Cypher will sort the result by the first variable listed, and for equals values, ---- MATCH (n) RETURN n.name, n.age -ORDER BY n.age, n.name + ORDER BY n.age, n.name ---- // end::clauses_order_by_multiple[] @@ -100,7 +100,7 @@ This returns the nodes, sorted first by their age, and then by their name. ---- MATCH (n) RETURN n.name, n.age -ORDER BY elementId(n) + ORDER BY elementId(n) ---- The nodes are returned, sorted by their internal ID. @@ -130,7 +130,7 @@ It is recommended to use application-generated IDs instead. ---- MATCH (n) RETURN n.name, n.age, n.length -ORDER BY keys(n) + ORDER BY keys(n) ---- The nodes are returned, sorted by their properties. @@ -156,7 +156,7 @@ By adding `DESC[ENDING]` after the variable to sort on, the sort will be done in ---- MATCH (n) RETURN n.name, n.age -ORDER BY n.name DESC + ORDER BY n.name DESC ---- The example returns the nodes, sorted by their name in reverse order. @@ -182,7 +182,7 @@ When sorting the result set, `null` will always come at the end of the result se ---- MATCH (n) RETURN n.length, n.name, n.age -ORDER BY n.length + ORDER BY n.length ---- The nodes are returned sorted by the length property, with a node without that property last. @@ -211,7 +211,8 @@ The `MERGE` and `SET` clauses also have ordering dependencies which can be contr [source, cypher] ---- MATCH (n) -WITH n ORDER BY n.age +WITH n + ORDER BY n.age RETURN collect(n.name) AS names ---- @@ -232,7 +233,7 @@ If it is an aggregating or `DISTINCT` projection, only the variables available i If the projection does not alter the output cardinality (which aggregation and `DISTINCT` do), variables available from before the projecting clause are also available. When the projection clause shadows already existing variables, only the new variables are available. -It is also not allowed to use aggregating expressions in the `ORDER BY` sub-clause if they are not also listed in the projecting clause. +It is also not allowed to use aggregating expressions in the `ORDER BY` subclause if they are not also listed in the projecting clause. This rule is to make sure that `ORDER BY` does not change the results, only the order of them. == ORDER BY and indexes diff --git a/modules/ROOT/pages/clauses/projection-read-subclauses.adoc b/modules/ROOT/pages/clauses/projection-read-subclauses.adoc new file mode 100644 index 000000000..42afe65aa --- /dev/null +++ b/modules/ROOT/pages/clauses/projection-read-subclauses.adoc @@ -0,0 +1,15 @@ += Read and projection subclauses +:description: anyInformation about Cypher's projection subclauses. + +Cypher's read and projection subclauses modify or constrain the results produced by read or projection clauses. +They should not be seen as separate clauses, but rather as part of the read or projection clauses they follow. + +The following subclauses are included in this category: + +* xref:clauses/limit.adoc[`LIMIT`]: constrains the number of rows projected by a `WITH` or `RETURN` clause. +* xref:clauses/order-by[`ORDER BY`]: orders the result projected by a `WITH` or `RETURN` clause. +* xref:clauses/skip.adoc[`SKIP`/ `OFFSET`]: defines from which row to start including the rows in the output of a `WITH` or `RETURN` clause. +* xref:clauses/where.adoc[`WHERE`]: constrains the pattern specified in a `MATCH` or `OPTIONAL MATCH` clause, or filters the result of a `WITH` clause. + +[NOTE] +`LIMIT`, `ORDER BY`, and `SKIP`/`OFFSET` can also be used as standalone clauses. \ No newline at end of file diff --git a/modules/ROOT/pages/clauses/projection.adoc b/modules/ROOT/pages/clauses/projection.adoc new file mode 100644 index 000000000..73dc7021e --- /dev/null +++ b/modules/ROOT/pages/clauses/projection.adoc @@ -0,0 +1,13 @@ += Projection clauses +:description: Information about Cypher's projection clauses. + +Cypher's projection clauses define which expressions appear in a query's result set (except for `FINISH`, which specifies that the query produces no result). +Returned expressions may be aliased using the `AS` keyword. + +The following clauses are included in this category: + +* xref:clauses/finish.adoc[`FINISH`]: ensures a query has no result while executing all side-effects. +* xref:clauses/let.adoc[`LET`]: binds values to variables. label:new[Introduced in Neo4j 2025.06] +* xref:clauses/return.adoc[`RETURN`]: defines what to include in the query result set. +* xref:clauses/unwind.adoc[`UNWIND`]: expands a list into a sequence of rows. +* xref:clauses/with.adoc[`WITH`]: chains query parts by passing, transforming, and controlling variables, enabling aggregations, filtering, ordering, and pagination. diff --git a/modules/ROOT/pages/clauses/read-write.adoc b/modules/ROOT/pages/clauses/read-write.adoc new file mode 100644 index 000000000..7155f6a78 --- /dev/null +++ b/modules/ROOT/pages/clauses/read-write.adoc @@ -0,0 +1,10 @@ += Read/Write clauses +:description: Information about Cypher's read/write clauses + +Read/write clauses can both both read data from the database, or write to it. + +The following clauses are included in this category: + +* xref:clauses/merge.adoc[`MERGE`]: ensures that a pattern exists in the graph. +If the pattern exists, `MERGE` matches it; if it does not exist, `MERGE` creates it. + diff --git a/modules/ROOT/pages/clauses/read.adoc b/modules/ROOT/pages/clauses/read.adoc new file mode 100644 index 000000000..37a21ff9d --- /dev/null +++ b/modules/ROOT/pages/clauses/read.adoc @@ -0,0 +1,10 @@ += Read clauses +:description: Information about Cypher's read clauses. + +Cypher's read clauses read data from the database. + +The following clauses are included in this category: + +* xref:clauses/filter.adoc[`FILTER`]: adds post-match filtering to queries. label:new[Introduced in Neo4j 2025.06] +* xref:clauses/match.adoc[`MATCH`]: specifies the patterns to search for in the database. +* xref:clauses/optional-match.adoc[`OPTIONAL MATCH`]: specifies the patterns to search for in a database, returning `null` for any parts of the pattern that are not found. \ No newline at end of file diff --git a/modules/ROOT/pages/clauses/return.adoc b/modules/ROOT/pages/clauses/return.adoc index 93cbb17fd..7c6100f0c 100644 --- a/modules/ROOT/pages/clauses/return.adoc +++ b/modules/ROOT/pages/clauses/return.adoc @@ -136,7 +136,7 @@ To introduce a variable made up of characters not contained in the English alpha [source, cypher] ---- MATCH (`/uncommon variable\`) -WHERE `/uncommon variable\`.name = 'Keanu Reeves' + WHERE `/uncommon variable\`.name = 'Keanu Reeves' RETURN `/uncommon variable\`.bornIn ---- diff --git a/modules/ROOT/pages/clauses/schema.adoc b/modules/ROOT/pages/clauses/schema.adoc new file mode 100644 index 000000000..e65eaee16 --- /dev/null +++ b/modules/ROOT/pages/clauses/schema.adoc @@ -0,0 +1,13 @@ += Schema clauses +:description: Information about Cypher's schema clauses. + +Cypher's schema clauses enable the creation, listing, and dropping of xref:constraints/index.adoc[constraints] and xref:indexes/index.adoc[indexes]. + +The following clauses are included in this category: + +* xref:constraints/managing-constraints.adoc#create-constraint[`CREATE CONSTRAINT`] +* xref:constraints/managing-constraints.adoc#list-constraints[`SHOW CONSTRAINTS`] +* xref:constraints/managing-constraints.adoc#drop-constraint[`DROP CONSTRAINTS`] +* xref:indexes/search-performance-indexes/managing-indexes.adoc#create-range-index[`CREATE INDEX`] +* xref:indexes/search-performance-indexes/managing-indexes.adoc#list-indexes[`SHOW INDEXES`] +* xref:indexes/search-performance-indexes/managing-indexes.adoc#drop-indexes[`DROP INDEX`]. \ No newline at end of file diff --git a/modules/ROOT/pages/clauses/skip.adoc b/modules/ROOT/pages/clauses/skip.adoc index b8436b80d..2ccacddac 100644 --- a/modules/ROOT/pages/clauses/skip.adoc +++ b/modules/ROOT/pages/clauses/skip.adoc @@ -48,8 +48,8 @@ The following query returns a subset of the result, starting from the fourth res ---- MATCH (n) RETURN n.name -ORDER BY n.name -SKIP 3 + ORDER BY n.name + SKIP 3 ---- .Result @@ -74,9 +74,9 @@ The following query returns the middle two rows, with `SKIP` skipping the first ---- MATCH (n) RETURN n.name -ORDER BY n.name -SKIP 1 -LIMIT 2 + ORDER BY n.name + SKIP 1 + LIMIT 2 ---- // end::clauses_skip[] @@ -103,8 +103,8 @@ This query skips the first row and then xref:functions/mathematical-numeric.adoc ---- MATCH (n) RETURN n.name -ORDER BY n.name -SKIP 1 + toInteger(3 * rand()) + ORDER BY n.name + SKIP 1 + toInteger(3 * rand()) ---- .Result diff --git a/modules/ROOT/pages/clauses/transaction-clauses.adoc b/modules/ROOT/pages/clauses/transaction-clauses.adoc index bd2a93ccc..57fd46895 100644 --- a/modules/ROOT/pages/clauses/transaction-clauses.adoc +++ b/modules/ROOT/pages/clauses/transaction-clauses.adoc @@ -265,7 +265,8 @@ For example, getting the databases for all transactions where the currently exec .Query [source, cypher, role=test-result-skip] ---- -SHOW TRANSACTIONS YIELD database, currentQuery WHERE currentQuery contains 'Mark' +SHOW TRANSACTIONS YIELD database, currentQuery + WHERE currentQuery CONTAINS 'Mark' ---- .Result @@ -436,7 +437,7 @@ For example, returning the transaction IDs and message for the transactions that ---- TERMINATE TRANSACTIONS "neo4j-transaction-1","neo4j-transaction-2" YIELD transactionId, message -WHERE message <> "Transaction terminated." + WHERE message <> "Transaction terminated." ---- .Result @@ -459,7 +460,7 @@ In difference to `SHOW TRANSACTIONS`; the `TERMINATE TRANSACTIONS` does not allo [source, cypher, role=test-fail] ---- TERMINATE TRANSACTIONS "neo4j-transaction-1","neo4j-transaction-2" -WHERE message <> "Transaction terminated." + WHERE message <> "Transaction terminated." ---- .Error message @@ -501,7 +502,7 @@ To terminate all transactions by a user, first find the transactions using `SHOW ---- SHOW TRANSACTIONS YIELD transactionId AS txId, username AS user -WHERE user = "Alice" + WHERE user = "Alice" TERMINATE TRANSACTIONS txId YIELD message RETURN txId, message @@ -534,7 +535,7 @@ The following example shows a transaction that has been waiting for `40` minutes ---- SHOW TRANSACTIONS YIELD transactionId, waitTime -WHERE waitTime > duration({minutes: 30}) + WHERE waitTime > duration({minutes: 30}) TERMINATE TRANSACTIONS transactionId YIELD username, message RETURN * @@ -566,7 +567,7 @@ TERMINATE TRANSACTION 'neo4j-transaction-1', 'neo4j-transaction-2' YIELD username AS terminatedUser SHOW TRANSACTIONS YIELD username AS showUser, transactionId AS txId, database, currentQuery, status -WHERE showUser = terminatedUser AND NOT status STARTS WITH 'Terminated' + WHERE showUser = terminatedUser AND NOT status STARTS WITH 'Terminated' RETURN txId, showUser AS user, database, currentQuery ---- @@ -598,7 +599,7 @@ SHOW TRANSACTION 'neo4j-transaction-1' YIELD username AS originalUser, transactionId AS originalTxId SHOW TRANSACTIONS YIELD username AS newUser, transactionId AS txId, database, currentQuery, status -WHERE newUser = originalUser AND NOT txId = originalTxId + WHERE newUser = originalUser AND NOT txId = originalTxId RETURN txId, newUser AS user, database, currentQuery, status ---- diff --git a/modules/ROOT/pages/clauses/unwind.adoc b/modules/ROOT/pages/clauses/unwind.adoc index 55a739fd2..f84f269b5 100644 --- a/modules/ROOT/pages/clauses/unwind.adoc +++ b/modules/ROOT/pages/clauses/unwind.adoc @@ -222,7 +222,8 @@ Create a number of nodes and relationships from a parameter-list without using ` UNWIND $events AS event MERGE (y:Year {year: event.year}) MERGE (y)<-[:IN]-(e:Event {id: event.id}) -RETURN e.id AS x ORDER BY x +RETURN e.id AS x + ORDER BY x ---- // end::clauses_unwind_create_nodes[] diff --git a/modules/ROOT/pages/clauses/where.adoc b/modules/ROOT/pages/clauses/where.adoc index 08893446e..f80063423 100644 --- a/modules/ROOT/pages/clauses/where.adoc +++ b/modules/ROOT/pages/clauses/where.adoc @@ -47,7 +47,7 @@ CREATE (andy:Swedish:Person {name: 'Andy', age: 36}), [source, cypher] ---- MATCH (n) -WHERE n:Swedish + WHERE n:Swedish RETURN n.name AS name ---- // end::clauses_where_node_label[] @@ -67,7 +67,7 @@ RETURN n.name AS name [source, cypher] ---- MATCH (n:Person) -WHERE n.age < 35 + WHERE n.age < 35 RETURN n.name AS name, n.age AS age ---- // end::clauses_where_node_property[] @@ -87,7 +87,7 @@ RETURN n.name AS name, n.age AS age [source, cypher] ---- MATCH (:Person {name:'Andy'})-[k:KNOWS]->(f) -WHERE k.since < 2000 + WHERE k.since < 2000 RETURN f.name AS oldFriend ---- // end::clauses_where_relationship_property[] @@ -121,7 +121,7 @@ To filter on a property using a dynamically computed name, use square brackets ` [source, cypher] ---- MATCH (n:Person) -WHERE n[$propname] > 40 + WHERE n[$propname] > 40 RETURN n.name AS name, n.age AS age ---- // end::clauses_where_dynamic[] @@ -161,7 +161,7 @@ However, because `WHERE` is a subclause and not a clause, its scope is not limit ---- MATCH (n:Person) WITH n.name as name -WHERE n.age = 38 + WHERE n.age = 38 RETURN name ---- // end::clauses_where_with[] diff --git a/modules/ROOT/pages/clauses/with.adoc b/modules/ROOT/pages/clauses/with.adoc index a4f1452a8..583c323bc 100644 --- a/modules/ROOT/pages/clauses/with.adoc +++ b/modules/ROOT/pages/clauses/with.adoc @@ -243,7 +243,7 @@ RETURN p.name AS product, p.price AS price, isAffordable, discountCategory -ORDER BY price + ORDER BY price ---- // end::clauses_with_chain_expressions[] @@ -283,7 +283,7 @@ WITH c.firstName AS customer, RETURN customer, totalSpent, productsBought -ORDER BY totalSpent DESC + ORDER BY totalSpent DESC ---- // end::clauses_with_aggregations[] @@ -318,7 +318,7 @@ In the below query, `WITH DISTINCT` is used to remove any duplicate `discount` p MATCH (c:Customer) WITH DISTINCT c.discount AS discountRates RETURN discountRates -ORDER BY discountRates + ORDER BY discountRates ---- // end::clauses_with_remove_duplicates[] @@ -349,7 +349,7 @@ Using it is functionally the same as using simple `WITH`. MATCH (c:Customer) WITH ALL c.discount AS discountRates RETURN discountRates -ORDER BY discountRates + ORDER BY discountRates ---- .Result diff --git a/modules/ROOT/pages/clauses/write.adoc b/modules/ROOT/pages/clauses/write.adoc new file mode 100644 index 000000000..c72940ca6 --- /dev/null +++ b/modules/ROOT/pages/clauses/write.adoc @@ -0,0 +1,15 @@ += Write clauses +:description: Information about Cypher's write clauses. + +Cypher's write clauses write data to the database. + +The following clauses are included in this category: + +* xref::clauses/create.adoc[`CREATE`]: creates nodes and relationships. +* xref::clauses/delete.adoc[`DELETE`]: deletes nodes, relationships, or paths. +Deleted nodes myst also have all associated relationships explicitly deleted. +* xref::clauses/delete.adoc#delete-all-nodes-and-relationships[`DETACH DELETE`]: deletes a node or set of nodes. +All connecting relationships will be automatically deleted. +* xref::clauses/foreach.adoc[`FOREACH`]: iterates over a list to perform updates on each element. +* xref::clauses/set.adoc[`SET`]: updates labels on nodes and properties on nodes and relationships. +* xref::clauses/remove.adoc[`REMOVE`]: removes properties and labels from nodes and relationships. \ No newline at end of file diff --git a/modules/ROOT/pages/constraints/managing-constraints.adoc b/modules/ROOT/pages/constraints/managing-constraints.adoc index 2975482a9..9a282547f 100644 --- a/modules/ROOT/pages/constraints/managing-constraints.adoc +++ b/modules/ROOT/pages/constraints/managing-constraints.adoc @@ -923,7 +923,8 @@ These indexes are listed in the `owningConstraint` column returned by the xref:i .Query [source, cypher, test-exclude-cols=id] ---- -SHOW CONSTRAINTS WHERE ownedIndex IS NOT NULL +SHOW CONSTRAINTS + WHERE ownedIndex IS NOT NULL ---- .Result @@ -952,7 +953,8 @@ SHOW CONSTRAINTS WHERE ownedIndex IS NOT NULL .Query [source, cypher, test-exclude-cols=id] ---- -SHOW INDEXES WHERE owningConstraint IS NOT NULL +SHOW INDEXES + WHERE owningConstraint IS NOT NULL ---- .Result @@ -1276,7 +1278,7 @@ Therefore, all the data should be checked and cleaned up before re-attempting th [source, cypher] ---- MATCH (book1:Book), (book2:Book) -WHERE book1.title = book2.title AND NOT book1 = book2 + WHERE book1.title = book2.title AND NOT book1 = book2 RETURN book1, book2 ---- @@ -1311,7 +1313,7 @@ Therefore, all the data should be checked and cleaned up before re-attempting th [source, cypher] ---- MATCH ()-[wrote:WROTE]-() -WHERE wrote.language IS NULL + WHERE wrote.language IS NULL RETURN wrote ---- @@ -1328,7 +1330,7 @@ a| [source] ---- MATCH (n1:Label), (n2:Label) -WHERE n1.prop = n2.prop AND NOT n1 = n2 + WHERE n1.prop = n2.prop AND NOT n1 = n2 RETURN n1, n2 ---- @@ -1337,7 +1339,7 @@ a| [source] ---- MATCH ()-[r1:REL_TYPE]->(), ()-[r2:REL_TYPE]->() -WHERE r1.prop = r2.prop AND NOT r1 = r2 + WHERE r1.prop = r2.prop AND NOT r1 = r2 RETURN r1, r2 ---- @@ -1346,7 +1348,7 @@ a| [source] ---- MATCH (n:Label) -WHERE n.prop IS NULL + WHERE n.prop IS NULL RETURN n ---- @@ -1355,7 +1357,7 @@ a| [source] ---- MATCH ()-[r:REL_TYPE]->() -WHERE r.prop IS NULL + WHERE r.prop IS NULL RETURN r ---- @@ -1364,7 +1366,7 @@ a| [source] ---- MATCH (n:Label) -WHERE n.prop IS NOT :: + WHERE n.prop IS NOT :: RETURN n ---- @@ -1373,7 +1375,7 @@ a| [source] ---- MATCH ()-[r:REL_TYPE]->() -WHERE r.prop IS NOT :: + WHERE r.prop IS NOT :: RETURN r ---- @@ -1382,12 +1384,12 @@ a| [source] ---- MATCH (n1:Label), (n2:Label) -WHERE n1.prop = n2.prop AND NOT n1 = n2 + WHERE n1.prop = n2.prop AND NOT n1 = n2 UNWIND [n1, n2] AS node RETURN node, 'non-unique' AS reason UNION MATCH (n:Label) -WHERE n.prop IS NULL + WHERE n.prop IS NULL RETURN n AS node, 'non-existing' AS reason ---- @@ -1396,12 +1398,12 @@ a| [source] ---- MATCH ()-[r1:REL_TYPE]->(), ()-[r2:REL_TYPE]->() -WHERE r1.prop = r2.prop AND NOT r1 = r2 + WHERE r1.prop = r2.prop AND NOT r1 = r2 UNWIND [r1, r2] AS relationship RETURN relationship, 'non-unique' AS reason UNION MATCH ()-[r:REL_TYPE]->() -WHERE r.prop IS NULL + WHERE r.prop IS NULL RETURN r AS relationship, 'non-existing' AS reason ---- @@ -1533,7 +1535,7 @@ For a full list of all the constraint types (and synonyms) available in this com [source, cypher, test-exclude-cols=id] ---- SHOW CONSTRAINTS -WHERE entityType = 'RELATIONSHIP' + WHERE entityType = 'RELATIONSHIP' ---- .Result diff --git a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc index dc2727e3d..c98d4dfdc 100644 --- a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc +++ b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc @@ -2244,7 +2244,7 @@ label:updated[] ALTER DATABASE ... [WAIT [n [SEC[OND[S]]]]\|NOWAIT] ---- a| -New sub-clause `WAIT` for `ALTER DATABASE`. +New subclause `WAIT` for `ALTER DATABASE`. This enables adding a waiting clause to specify a time limit in which the command must be completed and returned. a| @@ -3607,7 +3607,7 @@ label:new[] CREATE DATABASE ... TOPOLOGY n PRIMAR{Y\|IES} [m SECONDAR{Y\|IES}] ---- a| -New sub-clause for `CREATE DATABASE`, to specify the number of servers hosting a database, when creating a database in cluster environments. +New subclause for `CREATE DATABASE`, to specify the number of servers hosting a database, when creating a database in cluster environments. a| [[cypher-5_0-a_8]] @@ -3618,7 +3618,7 @@ label:new[] ALTER DATABASE ... SET TOPOLOGY n PRIMAR{Y\|IES} [m SECONDAR{Y\|IES}] ---- a| -New sub-clause for `ALTER DATABASE`, which allows modifying the number of servers hosting a database in cluster environments. +New subclause for `ALTER DATABASE`, which allows modifying the number of servers hosting a database in cluster environments. a| [[cypher-5_0-a_9]] diff --git a/modules/ROOT/pages/expressions/list-expressions.adoc b/modules/ROOT/pages/expressions/list-expressions.adoc index 2426d776b..da617767f 100644 --- a/modules/ROOT/pages/expressions/list-expressions.adoc +++ b/modules/ROOT/pages/expressions/list-expressions.adoc @@ -519,8 +519,9 @@ The below query iterates over the `skills` property of each `Person` node and cr // tag::expressions_list_comprehension_properties[] [source, cypher] ---- -MATCH (p:Person) WHERE p.skills IS NOT NULL -ORDER BY p.name +MATCH (p:Person) + WHERE p.skills IS NOT NULL + ORDER BY p.name RETURN p.name AS name, [skill IN p.skills | skill + " expert"] AS modifiedSkills ---- diff --git a/modules/ROOT/pages/expressions/predicates/boolean-operators.adoc b/modules/ROOT/pages/expressions/predicates/boolean-operators.adoc index f59bf000b..348223987 100644 --- a/modules/ROOT/pages/expressions/predicates/boolean-operators.adoc +++ b/modules/ROOT/pages/expressions/predicates/boolean-operators.adoc @@ -54,7 +54,7 @@ CREATE (alice:Person {name:'Alice', age: 65, role: 'Project manager', email: 'al [source, cypher] ---- MATCH (n:Person) -WHERE n.age > 30 AND n.role = 'Software developer' + WHERE n.age > 30 AND n.role = 'Software developer' RETURN n.name AS name, n.age AS age, n.role AS role ---- // end::expressions_predicates_boolean_operators_and[] @@ -74,7 +74,7 @@ RETURN n.name AS name, n.age AS age, n.role AS role [source, cypher] ---- MATCH (n:Person) -WHERE n.age < 30 OR n.role = 'Software developer' + WHERE n.age < 30 OR n.role = 'Software developer' RETURN n.name AS name, n.age AS age, n.role AS role ---- // end::expressions_predicates_boolean_operators_or[] @@ -95,7 +95,7 @@ RETURN n.name AS name, n.age AS age, n.role AS role [source, cypher] ---- MATCH (n:Person) -WHERE n.age > 30 XOR n.role = 'Software developer' + WHERE n.age > 30 XOR n.role = 'Software developer' RETURN n.name AS name, n.age AS age, n.role AS role ---- // end::expressions_predicates_boolean_operators_xor[] @@ -119,7 +119,7 @@ RETURN n.name AS name, n.age AS age, n.role AS role [source, cypher] ---- MATCH (n:Person) -WHERE NOT n.age = 39 + WHERE NOT n.age = 39 RETURN n.name AS name, n.age AS age ---- // end::expressions_predicates_boolean_operators_not[] @@ -141,7 +141,7 @@ RETURN n.name AS name, n.age AS age [source, cypher] ---- MATCH (n:Person) -WHERE n.role = 'Software developer' XOR (n.age > 60 AND n.role = 'Security engineer') OR NOT (n.role = 'Director' OR n.name = 'Eskil') + WHERE n.role = 'Software developer' XOR (n.age > 60 AND n.role = 'Security engineer') OR NOT (n.role = 'Director' OR n.name = 'Eskil') RETURN n.name AS name, n.age AS age, n.role AS role ---- diff --git a/modules/ROOT/pages/expressions/predicates/comparison-operators.adoc b/modules/ROOT/pages/expressions/predicates/comparison-operators.adoc index 71266bc9f..44763bf11 100644 --- a/modules/ROOT/pages/expressions/predicates/comparison-operators.adoc +++ b/modules/ROOT/pages/expressions/predicates/comparison-operators.adoc @@ -48,7 +48,7 @@ CREATE (alice:Person {name:'Alice', age: 65, role: 'Project manager', email: 'al [source, cypher] ---- MATCH (n:Person) -WHERE n.role = 'Software developer' + WHERE n.role = 'Software developer' RETURN n.name AS name, n.role AS role ---- // end::expressions_predicates_comparison_operators_equality[] @@ -69,7 +69,7 @@ RETURN n.name AS name, n.role AS role [source, cypher] ---- MATCH (n:Person) -WHERE n.role <> 'Software developer' + WHERE n.role <> 'Software developer' RETURN n.name AS name, n.role AS role ---- // end::expressions_predicates_comparison_operators_inequality[] @@ -92,7 +92,7 @@ RETURN n.name AS name, n.role AS role [source, cypher] ---- MATCH (n:Person) -WHERE n.age < 39 + WHERE n.age < 39 RETURN n.name AS name, n.age AS age ---- // end::expressions_predicates_comparison_operators_less_than[] @@ -113,7 +113,7 @@ RETURN n.name AS name, n.age AS age [source, cypher] ---- MATCH (n:Person) -WHERE n.age <= 39 + WHERE n.age <= 39 RETURN n.name AS name, n.age AS age ---- // end::expressions_predicates_comparison_operators_less_than_or_equal[] @@ -136,7 +136,7 @@ RETURN n.name AS name, n.age AS age [source, cypher] ---- MATCH (n:Person) -WHERE n.age > 39 + WHERE n.age > 39 RETURN n.name AS name, n.age AS age ---- // end::expressions_predicates_comparison_operators_greater_than[] @@ -157,7 +157,7 @@ RETURN n.name AS name, n.age AS age [source, cypher] ---- MATCH (n:Person) -WHERE n.age >= 39 + WHERE n.age >= 39 RETURN n.name AS name, n.age AS age ---- // end::expressions_predicates_comparison_operators_greater_than_or_equal[] @@ -180,7 +180,7 @@ RETURN n.name AS name, n.age AS age [source, cypher] ---- MATCH (n:Person) -WHERE n.email IS NULL + WHERE n.email IS NULL RETURN n.name AS name ---- // end::expressions_predicates_comparison_operators_is_null[] @@ -202,7 +202,7 @@ RETURN n.name AS name [source, cypher] ---- MATCH (n:Person) -WHERE n.email IS NOT NULL + WHERE n.email IS NOT NULL RETURN n.name AS name, n.email AS email ---- // end::expressions_predicates_comparison_operators_is_not_null[] diff --git a/modules/ROOT/pages/expressions/predicates/list-operators.adoc b/modules/ROOT/pages/expressions/predicates/list-operators.adoc index 78bd021c8..f4cb8c6be 100644 --- a/modules/ROOT/pages/expressions/predicates/list-operators.adoc +++ b/modules/ROOT/pages/expressions/predicates/list-operators.adoc @@ -41,7 +41,7 @@ CREATE (alice:Person {name:'Alice', age: 65, role: 'Project manager', email: 'al [source, cypher] ---- MATCH (n:Person) -WHERE n.role IN ['Software developer', 'Project manager'] + WHERE n.role IN ['Software developer', 'Project manager'] RETURN n.name AS name, n.role AS role ---- // end::expressions_predicates_list_operators_in[] @@ -63,7 +63,7 @@ RETURN n.name AS name, n.role AS role ---- MATCH (p:Person) WITH p, ['Software developer', 'CEO'] AS roles -WHERE p.role IN roles + WHERE p.role IN roles RETURN p.name AS name, p.role AS role ---- @@ -86,10 +86,10 @@ The below query finds `Person` nodes that share the `role` of `Cecil` or `Eskil` ---- WITH ['Cecil', 'Eskil'] AS names MATCH (ce:Person) -WHERE ce.name IN names + WHERE ce.name IN names WITH collect(ce.role) AS roles, names MATCH (p:Person) -WHERE p.role IN roles AND NOT p.name IN names + WHERE p.role IN roles AND NOT p.name IN names RETURN p.name AS name, p.role AS role ---- diff --git a/modules/ROOT/pages/expressions/predicates/path-pattern-expressions.adoc b/modules/ROOT/pages/expressions/predicates/path-pattern-expressions.adoc index fdaf6f85f..60a73e240 100644 --- a/modules/ROOT/pages/expressions/predicates/path-pattern-expressions.adoc +++ b/modules/ROOT/pages/expressions/predicates/path-pattern-expressions.adoc @@ -49,7 +49,7 @@ CREATE (alice:Person {name:'Alice', age: 65, role: 'Project manager'}), [source, cypher] ---- MATCH (employee:Person) -WHERE (employee)-[:WORKS_FOR]->(:Person {name: 'Alice'}) + WHERE (employee)-[:WORKS_FOR]->(:Person {name: 'Alice'}) RETURN employee.name AS employee ---- // end::expressions_predicates_path_pattern_expression[] @@ -70,7 +70,7 @@ RETURN employee.name AS employee [source, cypher] ---- MATCH (employee:Person) -WHERE NOT employee.name = 'Cecil' AND (employee)-[:WORKS_FOR]->(:Person {name: 'Alice'}) + WHERE NOT employee.name = 'Cecil' AND (employee)-[:WORKS_FOR]->(:Person {name: 'Alice'}) RETURN employee.name AS employee ---- // end::expressions_predicates_path_pattern_expression_boolean[] diff --git a/modules/ROOT/pages/expressions/predicates/string-operators.adoc b/modules/ROOT/pages/expressions/predicates/string-operators.adoc index 18355c8cf..77a4c136b 100644 --- a/modules/ROOT/pages/expressions/predicates/string-operators.adoc +++ b/modules/ROOT/pages/expressions/predicates/string-operators.adoc @@ -44,7 +44,7 @@ CREATE (alice:Person {name:'Alice', age: 65, role: 'Project manager', email: 'al [source, cypher] ---- MATCH (n:Person) -WHERE n.name STARTS WITH 'C' + WHERE n.name STARTS WITH 'C' RETURN n.name AS name ---- // end::expressions_predicates_string_operators_prefix[] @@ -66,7 +66,7 @@ RETURN n.name AS name [source, cypher] ---- MATCH (n:Person) -WHERE n.role ENDS WITH 'developer' + WHERE n.role ENDS WITH 'developer' RETURN n.name AS name, n.role AS role ---- // end::expressions_predicates_string_operators_suffix[] @@ -87,7 +87,7 @@ RETURN n.name AS name, n.role AS role [source, cypher] ---- MATCH (n:Person) -WHERE n.role CONTAINS 'eng' + WHERE n.role CONTAINS 'eng' RETURN n.name AS name, n.role AS role ---- // end::expressions_predicates_string_operators_substring[] @@ -120,7 +120,7 @@ Flags are given at the beginning of the regular expression. [source, cypher] ---- MATCH (n:Person) -WHERE n.email =~ '.*@company.com' + WHERE n.email =~ '.*@company.com' RETURN n.name AS name, n.email AS email ---- // end::expressions_predicates_string_operators_regex[] @@ -144,7 +144,7 @@ By pre-pending a regular expression with the flag `(?i)`, the whole expression b [source, cypher] ---- MATCH (n:Person) -WHERE n.name =~ '(?i)CEC.*' + WHERE n.name =~ '(?i)CEC.*' RETURN n.name ---- // end::expressions_predicates_string_operators_regex_flag[] @@ -175,7 +175,7 @@ To use these as ordinary characters without special meaning, escape them. [source, cypher] ---- MATCH (n:Person) -WHERE n.email =~ '.*\\.se' + WHERE n.email =~ '.*\\.se' RETURN n.name AS name, n.email AS email ---- diff --git a/modules/ROOT/pages/expressions/predicates/type-predicate-expressions.adoc b/modules/ROOT/pages/expressions/predicates/type-predicate-expressions.adoc index b471bf06b..de20fa79a 100644 --- a/modules/ROOT/pages/expressions/predicates/type-predicate-expressions.adoc +++ b/modules/ROOT/pages/expressions/predicates/type-predicate-expressions.adoc @@ -164,7 +164,7 @@ The following query finds all `Person` nodes with an `age` property that is an ` [source, cypher] ---- MATCH (n:Person) -WHERE n.age IS :: INTEGER AND n.age > 18 + WHERE n.age IS :: INTEGER AND n.age > 18 RETURN n.name AS name, n.age AS age ---- // end::expressions_predicates_type_predicate_properties[] diff --git a/modules/ROOT/pages/functions/aggregating.adoc b/modules/ROOT/pages/functions/aggregating.adoc index af4f631f5..0dcb81f2c 100644 --- a/modules/ROOT/pages/functions/aggregating.adoc +++ b/modules/ROOT/pages/functions/aggregating.adoc @@ -299,7 +299,7 @@ It shows the behavior of using both the `ALL` and the `DISTINCT` keywords: [source, cypher] ---- MATCH (p:Person)-->(friend:Person)-->(friendOfFriend:Person) -WHERE p.name = 'Keanu Reeves' + WHERE p.name = 'Keanu Reeves' RETURN friendOfFriend.name, count(friendOfFriend), count(ALL friendOfFriend), count(DISTINCT friendOfFriend) ---- @@ -647,7 +647,7 @@ The 50th percentile of the values in the property `age` is returned: [source, cypher] ---- MATCH (p:Person) -WHERE p.name IN ['Keanu Reeves', 'Liam Neeson', 'Carrie Anne Moss'] + WHERE p.name IN ['Keanu Reeves', 'Liam Neeson', 'Carrie Anne Moss'] RETURN stDev(p.age) ---- // end::functions_aggregating_stdev[] @@ -696,7 +696,7 @@ The standard deviation of the values in the property `age` is returned: [source, cypher] ---- MATCH (p:Person) -WHERE p.name IN ['Keanu Reeves', 'Liam Neeson', 'Carrie Anne Moss'] + WHERE p.name IN ['Keanu Reeves', 'Liam Neeson', 'Carrie Anne Moss'] RETURN stDevP(p.age) ---- // end::functions_aggregating_stdevp[] @@ -823,7 +823,7 @@ The example below will throw an error since `n.x`, which is not a grouping key, RETURN n.x + count(*) ---- -To sort the result set using aggregating functions, the aggregation must be included in the `ORDER BY` sub-clause following the `RETURN` clause. +To sort the result set using aggregating functions, the aggregation must be included in the `ORDER BY` subclause following the `RETURN` clause. [[grouping-key-examples]] === Examples diff --git a/modules/ROOT/pages/functions/graph.adoc b/modules/ROOT/pages/functions/graph.adoc index 2bec760c9..d98d09c72 100644 --- a/modules/ROOT/pages/functions/graph.adoc +++ b/modules/ROOT/pages/functions/graph.adoc @@ -120,7 +120,7 @@ Properties for all graphs on the current composite database are returned. ---- UNWIND graph.names() AS name WITH name, graph.propertiesByName(name) AS props -WHERE "A" IN props.tags + WHERE "A" IN props.tags CALL () { USE graph.byName(name) MATCH (n) diff --git a/modules/ROOT/pages/functions/list.adoc b/modules/ROOT/pages/functions/list.adoc index d66b4329d..a4845d3ff 100644 --- a/modules/ROOT/pages/functions/list.adoc +++ b/modules/ROOT/pages/functions/list.adoc @@ -63,7 +63,8 @@ CREATE // tag::functions_list_keys[] [source, cypher] ---- -MATCH (a) WHERE a.name = 'Alice' +MATCH (a) + WHERE a.name = 'Alice' RETURN keys(a) ---- // end::functions_list_keys[] @@ -112,7 +113,8 @@ A `LIST` containing the names of all the properties on the node bound to // tag::functions_list_labels[] [source, cypher] ---- -MATCH (a) WHERE a.name = 'Alice' +MATCH (a) + WHERE a.name = 'Alice' RETURN labels(a) ---- // end::functions_list_labels[] @@ -161,7 +163,7 @@ A `LIST` containing all the labels of the node bound to `a` is returned. [source, cypher] ---- MATCH p = (a)-->(b)-->(c) -WHERE a.name = 'Alice' AND c.name = 'Eskil' + WHERE a.name = 'Alice' AND c.name = 'Eskil' RETURN nodes(p) ---- // end::functions_list_nodes[] @@ -261,7 +263,7 @@ As such, Cypher's `reduce()` is analogous to the `fold` or `reduce` methods in f [source, cypher] ---- MATCH p = (a)-->(b)-->(c) -WHERE a.name = 'Alice' AND b.name = 'Bob' AND c.name = 'Daniel' + WHERE a.name = 'Alice' AND b.name = 'Bob' AND c.name = 'Daniel' RETURN reduce(totalAge = 0, n IN nodes(p) | totalAge + n.age) AS reduction ---- // end::functions_list_reduce[] @@ -309,7 +311,7 @@ The `age` property of all `NODE` values in the `PATH` are summed and returned as [source, cypher] ---- MATCH p = (a)-->(b)-->(c) -WHERE a.name = 'Alice' AND c.name = 'Eskil' + WHERE a.name = 'Alice' AND c.name = 'Eskil' RETURN relationships(p) ---- // end::functions_list_relationships[] @@ -394,7 +396,8 @@ RETURN reverse(ids) // tag::functions_list_tail[] [source, cypher] ---- -MATCH (a) WHERE a.name = 'Eskil' +MATCH (a) + WHERE a.name = 'Eskil' RETURN a.likedColors, tail(a.likedColors) ---- // end::functions_list_tail[] diff --git a/modules/ROOT/pages/functions/mathematical-numeric.adoc b/modules/ROOT/pages/functions/mathematical-numeric.adoc index 3401c5c24..96627f0cf 100644 --- a/modules/ROOT/pages/functions/mathematical-numeric.adoc +++ b/modules/ROOT/pages/functions/mathematical-numeric.adoc @@ -58,7 +58,8 @@ CREATE // tag::functions_mathematical_numeric_abs[] [source, cypher, indent=0] ---- -MATCH (a), (e) WHERE a.name = 'Alice' AND e.name = 'Eskil' +MATCH (a), (e) + WHERE a.name = 'Alice' AND e.name = 'Eskil' RETURN a.age, e.age, abs(a.age - e.age) ---- // end::functions_mathematical_numeric_abs[] diff --git a/modules/ROOT/pages/functions/predicate.adoc b/modules/ROOT/pages/functions/predicate.adoc index 25c6a714f..4a57de05e 100644 --- a/modules/ROOT/pages/functions/predicate.adoc +++ b/modules/ROOT/pages/functions/predicate.adoc @@ -66,8 +66,7 @@ CREATE [source, cypher, indent=0] ---- MATCH p = (a)-[*]->(b) -WHERE - a.name = 'Keanu Reeves' + WHERE a.name = 'Keanu Reeves' AND b.name = 'Guy Pearce' AND all(x IN nodes(p) WHERE x.age < 60) RETURN p @@ -137,7 +136,7 @@ RETURN all(i in emptyList WHERE true) as allTrue, all(i in emptyList WHERE false [source, cypher, indent=0] ---- MATCH (p:Person) -WHERE any(nationality IN p.nationality WHERE nationality = 'American') + WHERE any(nationality IN p.nationality WHERE nationality = 'American') RETURN p ---- // end::functions_predicate_any[] @@ -258,7 +257,7 @@ For information about the `EXISTS` subquery, which is more versatile than the `e [source, cypher] ---- MATCH (p:Person) -WHERE NOT isEmpty(p.nationality) + WHERE NOT isEmpty(p.nationality) RETURN p.name, p.nationality ---- // end::functions_predicate_is_empty[] @@ -286,7 +285,7 @@ This query returns every `Person` node in the graph with a set `nationality` pro [source, cypher, indent=0] ---- MATCH (n) -WHERE isEmpty(properties(n)) + WHERE isEmpty(properties(n)) RETURN n ---- @@ -307,7 +306,7 @@ Because the example graph contains no empty nodes, nothing is returned: [source, cypher, indent=0] ---- MATCH (p:Person) -WHERE isEmpty(p.address) + WHERE isEmpty(p.address) RETURN p.name AS name ---- @@ -363,8 +362,7 @@ xref:expressions/predicates/comparison-operators.adoc[`IS NULL` or `IS NOT NULL` [source, cypher, indent=0] ---- MATCH p = (n)-[*]->(b) -WHERE - n.name = 'Keanu Reeves' + WHERE n.name = 'Keanu Reeves' AND none(x IN nodes(p) WHERE x.age > 60) RETURN p ---- @@ -435,8 +433,7 @@ RETURN none(i IN emptyList WHERE true) as noneTrue, none(i IN emptyList WHERE fa [source, cypher, indent=0] ---- MATCH p = (n)-->(b) -WHERE - n.name = 'Keanu Reeves' + WHERE n.name = 'Keanu Reeves' AND single(x IN nodes(p) WHERE x.nationality = 'Northern Irish') RETURN p ---- diff --git a/modules/ROOT/pages/functions/scalar.adoc b/modules/ROOT/pages/functions/scalar.adoc index fe15917b1..b77b3c3aa 100644 --- a/modules/ROOT/pages/functions/scalar.adoc +++ b/modules/ROOT/pages/functions/scalar.adoc @@ -154,7 +154,7 @@ The number of Unicode characters in the `STRING` is returned. [source, cypher, indent=0] ---- MATCH (a) -WHERE a.name = 'Alice' + WHERE a.name = 'Alice' RETURN coalesce(a.hairColor, a.eyes) ---- // end::functions_scalar_coalesce[] @@ -326,7 +326,7 @@ RETURN endNode(r) [source, cypher, indent=0] ---- MATCH (a) -WHERE a.name = 'Eskil' + WHERE a.name = 'Eskil' RETURN a.likedColors, head(a.likedColors) ---- // end::functions_scalar_head[] @@ -456,7 +456,7 @@ The node identifier for each of the nodes is returned. [source, cypher, indent=0] ---- MATCH (a) -WHERE a.name = 'Eskil' + WHERE a.name = 'Eskil' RETURN a.likedColors, last(a.likedColors) ---- // end::functions_scalar_last[] @@ -506,7 +506,7 @@ To calculate the length of a `LIST` of the number of Unicode characters in a `ST [source, cypher, indent=0] ---- MATCH p = (a)-->(b)-->(c) -WHERE a.name = 'Alice' + WHERE a.name = 'Alice' RETURN length(p) ---- // end::functions_scalar_length[] @@ -758,7 +758,7 @@ The number of elements in the list is returned. [source, cypher, indent=0] ---- MATCH (a) -WHERE a.name = 'Alice' + WHERE a.name = 'Alice' RETURN size([p=(a)-->()-->() | p]) AS fof ---- @@ -784,7 +784,7 @@ The number of paths matching the pattern expression is returned. (The size of th [source, cypher, indent=0] ---- MATCH (a) -WHERE size(a.name) > 6 + WHERE size(a.name) > 6 RETURN size(a.name) ---- @@ -1206,7 +1206,7 @@ RETURN toIntegerOrNull('42'), toIntegerOrNull('not a number'), toIntegerOrNull(t [source, cypher, indent=0] ---- MATCH (n)-[r]->() -WHERE n.name = 'Alice' + WHERE n.name = 'Alice' RETURN type(r) ---- // end::functions_scalar_type[] diff --git a/modules/ROOT/pages/functions/spatial.adoc b/modules/ROOT/pages/functions/spatial.adoc index 3c9cce94d..f32709ece 100644 --- a/modules/ROOT/pages/functions/spatial.adoc +++ b/modules/ROOT/pages/functions/spatial.adoc @@ -457,7 +457,7 @@ WITH point({longitude: 12.53, latitude: 55.66}) AS lowerLeft, point({longitude: 12.614, latitude: 55.70}) AS upperRight MATCH (t:TrainStation) -WHERE point.withinBBox(point({longitude: t.longitude, latitude: t.latitude}), lowerLeft, upperRight) + WHERE point.withinBBox(point({longitude: t.longitude, latitude: t.latitude}), lowerLeft, upperRight) RETURN count(t) ---- // end::functions_spatial_point_cartesian_2d[] diff --git a/modules/ROOT/pages/functions/vector.adoc b/modules/ROOT/pages/functions/vector.adoc index 7664ae28a..2809bd65b 100644 --- a/modules/ROOT/pages/functions/vector.adoc +++ b/modules/ROOT/pages/functions/vector.adoc @@ -99,8 +99,8 @@ This is achieved by matching on all candidate vectors and ordering on the simila MATCH (node:Node) WITH node, vector.similarity.euclidean($query, node.vector) AS score RETURN node, score -ORDER BY score DESCENDING -LIMIT 2; + ORDER BY score DESCENDING + LIMIT 2 ---- This returns the two nearest neighbors. diff --git a/modules/ROOT/pages/genai-integrations.adoc b/modules/ROOT/pages/genai-integrations.adoc index 34c10bda4..0d64bad6d 100644 --- a/modules/ROOT/pages/genai-integrations.adoc +++ b/modules/ROOT/pages/genai-integrations.adoc @@ -95,7 +95,7 @@ The embeddings are stored as properties on nodes or relationships with the type [source,cypher,role=test-skip] ---- MATCH (m:Movie {title:'Godfather, The'}) -WHERE m.plot IS NOT NULL AND m.title IS NOT NULL + WHERE m.plot IS NOT NULL AND m.title IS NOT NULL WITH m, m.title || ' ' || m.plot AS titleAndPlot // <1> WITH m, genai.vector.encode(titleAndPlot, 'OpenAI', { token: $token }) AS propertyVector // <2> CALL db.create.setNodeVectorProperty(m, 'embedding', propertyVector) // <3> diff --git a/modules/ROOT/pages/indexes/search-performance-indexes/index-hints.adoc b/modules/ROOT/pages/indexes/search-performance-indexes/index-hints.adoc index 93d9cec90..bef8e490b 100644 --- a/modules/ROOT/pages/indexes/search-performance-indexes/index-hints.adoc +++ b/modules/ROOT/pages/indexes/search-performance-indexes/index-hints.adoc @@ -215,7 +215,7 @@ The following query can be tuned to pick a text index. PROFILE MATCH (c:Country) USING TEXT INDEX c:Country(name) -WHERE c.name = 'Country7' + WHERE c.name = 'Country7' RETURN * ---- @@ -307,7 +307,7 @@ The following query can be tuned to pick a text index. PROFILE MATCH ()-[i:INVENTED_BY]->() USING TEXT INDEX i:INVENTED_BY(location) -WHERE i.location = 'Location7' + WHERE i.location = 'Location7' RETURN * ---- @@ -408,7 +408,7 @@ PROFILE MATCH (country:Country) USING INDEX country:Country(name) USING INDEX country:Country(formed) -WHERE country.formed = 500 OR country.name STARTS WITH "A" + WHERE country.formed = 500 OR country.name STARTS WITH "A" RETURN * ---- @@ -576,7 +576,7 @@ PROFILE MATCH (person) USING SCAN person:Pioneer USING SCAN person:Scientist -WHERE person:Pioneer OR person:Scientist + WHERE person:Pioneer OR person:Scientist RETURN * ---- diff --git a/modules/ROOT/pages/indexes/search-performance-indexes/managing-indexes.adoc b/modules/ROOT/pages/indexes/search-performance-indexes/managing-indexes.adoc index 7780bc811..c803d3c10 100644 --- a/modules/ROOT/pages/indexes/search-performance-indexes/managing-indexes.adoc +++ b/modules/ROOT/pages/indexes/search-performance-indexes/managing-indexes.adoc @@ -564,7 +564,7 @@ MATCH (n:Label) [source, syntax, role="noheader"] ---- MATCH (n) -WHERE n:Label + WHERE n:Label ---- | Relationship type predicate. @@ -577,7 +577,7 @@ MATCH ()-[r:REL]->() [source, syntax, role="noheader"] ---- MATCH ()-[r]->() -WHERE r:REL + WHERE r:REL ---- |=== @@ -897,7 +897,8 @@ To show only range indexes that does not belong to a constraint we can combine t .Showing range indexes [source, cypher, role=test-result-skip] ---- -SHOW RANGE INDEXES WHERE owningConstraint IS NULL +SHOW RANGE INDEXES + WHERE owningConstraint IS NULL ---- .Result @@ -922,7 +923,8 @@ To get all columns, use: [source, syntax, role="noheader"] ---- -SHOW RANGE INDEXES YIELD * WHERE owningConstraint IS NULL +SHOW RANGE INDEXES YIELD * + WHERE owningConstraint IS NULL ---- [[listing-indexes-result-columns]] diff --git a/modules/ROOT/pages/indexes/search-performance-indexes/using-indexes.adoc b/modules/ROOT/pages/indexes/search-performance-indexes/using-indexes.adoc index c6c5ac17a..cf86362d1 100644 --- a/modules/ROOT/pages/indexes/search-performance-indexes/using-indexes.adoc +++ b/modules/ROOT/pages/indexes/search-performance-indexes/using-indexes.adoc @@ -44,7 +44,7 @@ For more information, see xref:planning-and-tuning/index.adoc#profile-and-explai ---- PROFILE MATCH (n:PointOfInterest) -WHERE n.type = 'baseball' + WHERE n.type = 'baseball' RETURN count(n) ---- @@ -110,7 +110,7 @@ For more information about creating indexes, see xref:indexes/search-performance ---- PROFILE MATCH (n:PointOfInterest) -WHERE n.type = 'baseball' + WHERE n.type = 'baseball' RETURN count(n) ---- @@ -170,7 +170,7 @@ The following query filters all `PointOfInterest` nodes with a `name` property t ---- PROFILE MATCH (n:PointOfInterest) -WHERE n.name CONTAINS 'William' + WHERE n.name CONTAINS 'William' RETURN n.name AS name, n.type AS type ---- @@ -210,7 +210,7 @@ If, however, the query is changed to use the `STARTS WITH` operator instead of ` ---- PROFILE MATCH (n:PointOfInterest) -WHERE n.name STARTS WITH 'William' + WHERE n.name STARTS WITH 'William' RETURN n.name, n.type ---- @@ -297,7 +297,7 @@ CREATE POINT INDEX point_index_location FOR (n:PointOfInterest) ON (n.location) ---- PROFILE MATCH (n:PointOfInterest) -WHERE point.withinBBox( + WHERE point.withinBBox( n.location, point({srid: 4326, x: -73.9723702, y: 40.7697989}), point({srid: 4326, x: -73.9725659, y: 40.770193})) @@ -394,8 +394,8 @@ MATCH (tennisPitch: PointOfInterest {name: 'pitch', type: 'tennis'}) WITH tennisPitch MATCH path = shortestPath((tennisPitch)-[:ROUTE*]-(:PointOfInterest {name: 'Zoo School'})) WITH path, relationships(path) AS relationships -ORDER BY length(path) ASC -LIMIT 1 + ORDER BY length(path) ASC + LIMIT 1 UNWIND relationships AS rel RETURN length(path) AS pathLength, sum(rel.distance) AS geographicalDistance ---- @@ -470,7 +470,7 @@ Note the order in which the properties are defined when creating the index, with ---- PROFILE MATCH (n:PointOfInterest) -WHERE n.lat = 40.7697989 AND n.name STARTS WITH 'William' AND n.type IS NOT NULL + WHERE n.lat = 40.7697989 AND n.name STARTS WITH 'William' AND n.type IS NOT NULL RETURN n.name AS name ---- @@ -524,7 +524,7 @@ Note that the order of the properties has changed: the `name` property is now th ---- PROFILE MATCH (n:PointOfInterest) -WHERE n.lat = 40.769798 AND n.name STARTS WITH 'William' AND n.type IS NOT NULL + WHERE n.lat = 40.769798 AND n.name STARTS WITH 'William' AND n.type IS NOT NULL RETURN n.name AS name ---- @@ -586,9 +586,9 @@ To demonstrate this behavior, the following query will filter out any `ROUTE` re ---- PROFILE MATCH ()-[r:ROUTE]-() -WHERE r.distance < 30 + WHERE r.distance < 30 RETURN r.distance AS distance -ORDER BY distance + ORDER BY distance ---- .Execution plan @@ -631,9 +631,9 @@ Re-running the query, it now generates a different plan: ---- PROFILE MATCH ()-[r:ROUTE]-() -WHERE r.distance < 30 + WHERE r.distance < 30 RETURN r.distance AS distance -ORDER BY distance + ORDER BY distance ---- .Execution plan @@ -683,7 +683,7 @@ PROFILE MATCH (ws:PointOfInterest {name:'William Shakespeare'}) WITH ws MATCH (poi:PointOfInterest) -WHERE poi.lon > ws.lon + WHERE poi.lon > ws.lon RETURN poi.name AS name ---- @@ -723,7 +723,7 @@ The following query demonstrates the incompatibility between `null` values and i ---- PROFILE MATCH (n:PointOfInterest) -WHERE n.name IS NULL + WHERE n.name IS NULL RETURN count(n) AS nodes ---- @@ -763,7 +763,7 @@ The following query shows this by adding a substring predicate to the above quer ---- PROFILE MATCH (n:PointOfInterest) -WHERE n.name IS NULL OR n.name CONTAINS 'William' + WHERE n.name IS NULL OR n.name CONTAINS 'William' RETURN count(n) AS nodes ---- @@ -819,7 +819,7 @@ The following example uses the same query as above but exchanges `IS NULL` with ---- PROFILE MATCH (n:PointOfInterest) -WHERE n.name IS NOT NULL + WHERE n.name IS NOT NULL RETURN count(n) AS nodes ---- @@ -864,7 +864,7 @@ For example, if the `WHERE` predicate in the previous query is altered to instea ---- PROFILE MATCH (n:PointOfInterest) -WHERE n.name IS :: STRING NOT NULL + WHERE n.name IS :: STRING NOT NULL RETURN count(n) AS nodes ---- @@ -909,7 +909,7 @@ DROP INDEX range_index_name ---- PROFILE MATCH (n:PointOfInterest) -WHERE n.name IS NOT NULL + WHERE n.name IS NOT NULL RETURN count(n) AS nodes ---- @@ -948,7 +948,7 @@ FOR (n:PointOfInterest) REQUIRE n.name IS :: STRING ---- PROFILE MATCH (n:PointOfInterest) -WHERE n.name IS NOT NULL + WHERE n.name IS NOT NULL RETURN count(n) AS nodes ---- diff --git a/modules/ROOT/pages/indexes/semantic-indexes/full-text-indexes.adoc b/modules/ROOT/pages/indexes/semantic-indexes/full-text-indexes.adoc index ff18a4f06..9aa2e081e 100644 --- a/modules/ROOT/pages/indexes/semantic-indexes/full-text-indexes.adoc +++ b/modules/ROOT/pages/indexes/semantic-indexes/full-text-indexes.adoc @@ -302,7 +302,8 @@ Similar to search-performance indexes, the `SHOW` command can be filtered for pa .Show full-text indexes using filtering [source, cypher, test-exclude-cols=id] ---- -SHOW FULLTEXT INDEXES WHERE name CONTAINS "Team" +SHOW FULLTEXT INDEXES + WHERE name CONTAINS "Team" ---- .Result diff --git a/modules/ROOT/pages/introduction/cypher-overview.adoc b/modules/ROOT/pages/introduction/cypher-overview.adoc index 865cde7bf..1eed64b7c 100644 --- a/modules/ROOT/pages/introduction/cypher-overview.adoc +++ b/modules/ROOT/pages/introduction/cypher-overview.adoc @@ -53,7 +53,7 @@ WHERE movie.rating > 7 [source, cypher] ---- MATCH (movie:Movie) -WHERE movie.rating > 7 + WHERE movie.rating > 7 RETURN movie.title ---- diff --git a/modules/ROOT/pages/patterns/non-linear-patterns.adoc b/modules/ROOT/pages/patterns/non-linear-patterns.adoc index 595dc307e..c7545249f 100644 --- a/modules/ROOT/pages/patterns/non-linear-patterns.adoc +++ b/modules/ROOT/pages/patterns/non-linear-patterns.adoc @@ -194,12 +194,13 @@ MATCH (:Station {name: 'Starbeck'})<-[:CALLS_AT]- (n:Stop)-[:CALLS_AT]->(lds), (lds)<-[:CALLS_AT]-(x:Stop)-[:NEXT]->*(y:Stop)-[:CALLS_AT]-> (:Station {name: 'Huddersfield'}) -WHERE b.arrives < m.departs AND n.arrives < x.departs + WHERE b.arrives < m.departs AND n.arrives < x.departs RETURN a.departs AS departs, l.name AS changeAt, m.departs AS changeDeparts, y.arrives AS arrives -ORDER BY y.arrives LIMIT 1 + ORDER BY y.arrives + LIMIT 1 ---- // end::patterns_non_linear_patterns_graph_pattern[] diff --git a/modules/ROOT/pages/patterns/primer.adoc b/modules/ROOT/pages/patterns/primer.adoc index 30604a3ad..ade9117ef 100644 --- a/modules/ROOT/pages/patterns/primer.adoc +++ b/modules/ROOT/pages/patterns/primer.adoc @@ -273,8 +273,8 @@ MATCH (:Station {name: 'Denmark Hill'})<-[:CALLS_AT]- (:Station {name: 'Clapham Junction'})<-[:CALLS_AT]- (t1:Stop)-[:NEXT]->+(x)-[:NEXT]->+(:Stop)-[:CALLS_AT]-> (:Station {name: 'London Victoria'}) -WHERE t1.departs = time('22:46') - AND s2.arrives < x.departs + WHERE t1.departs = time('22:46') + AND s2.arrives < x.departs RETURN s1.departs AS departure, s2.arrives AS changeArrival, c.name AS changeAt ---- diff --git a/modules/ROOT/pages/patterns/reference.adoc b/modules/ROOT/pages/patterns/reference.adoc index b653ab9b2..ae5119301 100644 --- a/modules/ROOT/pages/patterns/reference.adoc +++ b/modules/ROOT/pages/patterns/reference.adoc @@ -1229,7 +1229,7 @@ MATCH SHORTEST 2 ( p = ()--+() WHERE any(n IN nodes(p) WHERE n.p < 42) ) ---- // graph pattern WHERE clause MATCH p = SHORTEST 2 (a)--+() -WHERE all(n IN nodes(p) WHERE n.p < 42) + WHERE all(n IN nodes(p) WHERE n.p < 42) ---- [[shortest-paths-rules-partitions]] @@ -1360,7 +1360,7 @@ For every single shortest path connecting each distinct pair of nodes, only retu [source, role=noheader] ---- MATCH p = SHORTEST 2 ()--+() -WHERE length(p) % 2 = 0 + WHERE length(p) % 2 = 0 ---- [[shortest-functions]] @@ -1444,10 +1444,10 @@ If the `MATCH` clause of the `shortestPath()` function includes a `WHERE` clause [source] ---- MATCH p = shortestPath(()-[*]-()) -WHERE all(n in nodes(p) WHERE n.p < 42) + WHERE all(n in nodes(p) WHERE n.p < 42) MATCH p = shortestPath(()-[*]-()) -WHERE all(r in relationships(p) WHERE r.p < 42) + WHERE all(r in relationships(p) WHERE r.p < 42) ---- These contrast with `WHERE` clauses that are not part of the same `MATCH` clause. @@ -1457,7 +1457,7 @@ These contrast with `WHERE` clauses that are not part of the same `MATCH` clause ---- MATCH p = shortestPath(()-[*]-()) WITH nodes(p) AS N -WHERE all(n in N WHERE n.p < 42) + WHERE all(n in N WHERE n.p < 42) ---- [[shortest-functions-rules-non-determinism]] @@ -1576,7 +1576,8 @@ The `WHERE` clause can refer to variables inside and outside of quantified path [source, role=noheader] ---- -(a)-->(b)-->(c), (b) ((d)-->(e))+ WHERE any(n in d WHERE n.p = a.p) +(a)-->(b)-->(c), (b) ((d)-->(e))+ + WHERE any(n in d WHERE n.p = a.p) ---- An equijoin can be formed to match "H" shaped graphs: diff --git a/modules/ROOT/pages/patterns/shortest-paths.adoc b/modules/ROOT/pages/patterns/shortest-paths.adoc index 441032ce5..2eccecd46 100644 --- a/modules/ROOT/pages/patterns/shortest-paths.adoc +++ b/modules/ROOT/pages/patterns/shortest-paths.adoc @@ -72,7 +72,7 @@ For example, the following example uses `SHORTEST 1` to return the length of the [source, cypher] ---- MATCH p = SHORTEST 1 (wos:Station)-[:LINK]-+(bmv:Station) -WHERE wos.name = "Worcester Shrub Hill" AND bmv.name = "Bromsgrove" + WHERE wos.name = "Worcester Shrub Hill" AND bmv.name = "Bromsgrove" RETURN length(p) AS result ---- // end::patterns_shortest_paths_shortest_k[] @@ -108,7 +108,7 @@ If instead `SHORTEST 2` is specified, all shortest paths in this example would b [source, cypher] ---- MATCH p = SHORTEST 2 (wos:Station)-[:LINK]-+(bmv:Station) -WHERE wos.name = "Worcester Shrub Hill" AND bmv.name = "Bromsgrove" + WHERE wos.name = "Worcester Shrub Hill" AND bmv.name = "Bromsgrove" RETURN [n in nodes(p) | n.name] AS stops ---- @@ -135,7 +135,7 @@ The following query returns all three of the second shortest paths, along with t [source, cypher] ---- MATCH p = SHORTEST 5 (wos:Station)-[:LINK]-+(bmv:Station) -WHERE wos.name = "Worcester Shrub Hill" AND bmv.name = "Bromsgrove" + WHERE wos.name = "Worcester Shrub Hill" AND bmv.name = "Bromsgrove" RETURN [n in nodes(p) | n.name] AS stops ---- @@ -166,7 +166,7 @@ To return all paths that are tied for shortest length, use the keywords `ALL SHO [source,cypher] ---- MATCH p = ALL SHORTEST (wos:Station)-[:LINK]-+(bmv:Station) -WHERE wos.name = "Worcester Shrub Hill" AND bmv.name = "Bromsgrove" + WHERE wos.name = "Worcester Shrub Hill" AND bmv.name = "Bromsgrove" RETURN [n in nodes(p) | n.name] AS stops ---- // end::patterns_shortest_paths_all_shortest[] @@ -195,7 +195,7 @@ For example, the following returns the first and second shortest length paths be [source,cypher] ---- MATCH p = SHORTEST 2 GROUPS (wos:Station)-[:LINK]-+(bmv:Station) -WHERE wos.name = "Worcester Shrub Hill" AND bmv.name = "Bromsgrove" + WHERE wos.name = "Worcester Shrub Hill" AND bmv.name = "Bromsgrove" RETURN [n in nodes(p) | n.name] AS stops, length(p) AS pathLength ---- // end::patterns_shortest_paths_shortest_k_groups[] @@ -221,7 +221,7 @@ For example, if the paths equal to one of the eight shortest paths are specified [source,cypher] ---- MATCH p = SHORTEST 8 GROUPS (wos:Station)-[:LINK]-+(bmv:Station) -WHERE wos.name = "Worcester Shrub Hill" AND bmv.name = "Bromsgrove" + WHERE wos.name = "Worcester Shrub Hill" AND bmv.name = "Bromsgrove" RETURN length(p) AS pathLength, count(*) AS numPaths ---- @@ -300,7 +300,7 @@ UNWIND ["Ashchurch", "Cheltenham Spa"] AS b MATCH SHORTEST 2 GROUPS (o:Station {name: a})-[l]-+(d:Station {name: b}) RETURN o.name AS start, d.name AS end, size(l) AS pathLength, count(*) AS numPaths -ORDER BY start, end, pathLength + ORDER BY start, end, pathLength ---- .Result @@ -361,7 +361,7 @@ MATCH SHORTEST 1 (:Station {name: 'Hartlebury'}) (()--(n:Station))+ (:Station {name: 'Cheltenham Spa'}) -WHERE none(stop IN n[..-1] WHERE stop.name = 'Bromsgrove') + WHERE none(stop IN n[..-1] WHERE stop.name = 'Bromsgrove') RETURN [stop in n[..-1] | stop.name] AS stops ---- @@ -435,7 +435,7 @@ To illustrate, consider this example that returns all shortest paths from `Hartl ---- MATCH p = SHORTEST 1 (:Station {name: 'Hartlebury'})--+(b:Station) RETURN b.name AS destination, length(p) AS pathLength -ORDER BY pathLength, destination + ORDER BY pathLength, destination ---- .Result @@ -463,9 +463,9 @@ It would return the results of the previous query with all routes with an odd nu [source,cypher] ---- MATCH p = SHORTEST 1 (:Station {name: 'Hartlebury'})--+(b:Station) -WHERE length(p) % 2 = 0 + WHERE length(p) % 2 = 0 RETURN b.name AS destination, length(p) AS pathLength -ORDER BY pathLength, destination + ORDER BY pathLength, destination ---- .Result @@ -490,7 +490,7 @@ MATCH SHORTEST 1 (p = (:Station {name: 'Hartlebury'})--+(b:Station) WHERE length(p) % 2 = 0 ) RETURN b.name AS destination, length(p) AS pathLength -ORDER BY pathLength, destination + ORDER BY pathLength, destination ---- .Result diff --git a/modules/ROOT/pages/patterns/variable-length-patterns.adoc b/modules/ROOT/pages/patterns/variable-length-patterns.adoc index af661f964..a2812170c 100644 --- a/modules/ROOT/pages/patterns/variable-length-patterns.adoc +++ b/modules/ROOT/pages/patterns/variable-length-patterns.adoc @@ -209,7 +209,7 @@ Continuing with the example of `Stations` and `Stops` from the previous section, MATCH (d:Station { name: 'Denmark Hill' })<-[:CALLS_AT]-(n:Stop) ((:Stop)-[:NEXT]->(:Stop)){1,10} (m:Stop)-[:CALLS_AT]->(a:Station { name: 'Clapham Junction' }) -WHERE m.arrives < time('17:18') + WHERE m.arrives < time('17:18') RETURN n.departs AS departureTime ---- @@ -221,7 +221,7 @@ If the relationship `NEXT` only connects `Stop` nodes, the `:Stop` label express MATCH (d:Station { name: 'Denmark Hill' })<-[:CALLS_AT]-(n:Stop) (()-[:NEXT]->()){1,10} (m:Stop)-[:CALLS_AT]->(a:Station { name: 'Clapham Junction' }) -WHERE m.arrives < time('17:18') + WHERE m.arrives < time('17:18') RETURN n.departs AS departureTime ---- @@ -236,7 +236,7 @@ Below is the previous query rewritten with a quantified relationship: MATCH (d:Station { name: 'Denmark Hill' })<-[:CALLS_AT]- (n:Stop)-[:NEXT]->{1,10}(m:Stop)-[:CALLS_AT]-> (a:Station { name: 'Clapham Junction' }) -WHERE m.arrives < time('17:18') + WHERE m.arrives < time('17:18') RETURN n.departs AS departureTime ---- // end::patterns_variable_length_patterns_quantified_relationships[] @@ -478,9 +478,9 @@ Whether any of these paths corresponds to the shortest path by distance can be c MATCH (bfr:Station {name: 'London Blackfriars'}), (ndl:Station {name: 'North Dulwich'}) MATCH p = (bfr)-[:LINK]-+(ndl) -RETURN reduce(acc = 0, r in relationships(p) | round(acc + r.distance, 2)) - AS distance -ORDER BY distance LIMIT 1 +RETURN reduce(acc = 0, r in relationships(p) | round(acc + r.distance, 2)) AS distance + ORDER BY distance + LIMIT 1 ---- .Result diff --git a/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc b/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc index 917387815..1b6018216 100644 --- a/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc +++ b/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc @@ -542,7 +542,7 @@ Although this is slower than an index seek (since all entries need to be examine ---- PROFILE MATCH (l:Location) -WHERE l.name CONTAINS 'al' + WHERE l.name CONTAINS 'al' RETURN l ---- @@ -586,7 +586,7 @@ Although this is slower than an index seek (since all entries need to be examine ---- PROFILE MATCH (l:Location) -WHERE l.name ENDS WITH 'al' + WHERE l.name ENDS WITH 'al' RETURN l ---- @@ -636,7 +636,7 @@ CREATE RANGE INDEX range_location_name FOR (l:Location) ON (l.name) ---- PROFILE MATCH (l:Location) -WHERE l.name IS NOT NULL + WHERE l.name IS NOT NULL RETURN l ---- @@ -679,7 +679,7 @@ It allows the index to be partitioned into different segments where each segment CYPHER runtime=parallel PROFILE MATCH (l:Location) -WHERE l.name IS NOT NULL + WHERE l.name IS NOT NULL RETURN l ---- @@ -721,7 +721,7 @@ The `NodeByElementIdSeek` operator reads one or more nodes by ID from the node s ---- PROFILE MATCH (n) -WHERE elementId(n) = 0 + WHERE elementId(n) = 0 RETURN n ---- @@ -763,7 +763,7 @@ The `NodeByIdSeek` operator reads one or more nodes by id from the node store, s ---- PROFILE MATCH (n) -WHERE id(n) = 0 + WHERE id(n) = 0 RETURN n ---- @@ -1061,7 +1061,7 @@ If the index is a unique index, the operator is instead called `NodeUniqueIndexS ---- PROFILE MATCH (l:Location) -WHERE l.name STARTS WITH 'Lon' + WHERE l.name STARTS WITH 'Lon' RETURN l ---- @@ -1106,7 +1106,7 @@ It allows the index to be partitioned into different segments where each segment CYPHER runtime=parallel PROFILE MATCH (l:Location) -WHERE l.name STARTS WITH 'Lon' + WHERE l.name STARTS WITH 'Lon' RETURN l ---- @@ -1151,7 +1151,7 @@ If the index is not unique, the operator is instead called `NodeIndexSeekByRange ---- PROFILE MATCH (t:Team) -WHERE t.name STARTS WITH 'Ma' + WHERE t.name STARTS WITH 'Ma' RETURN t ---- @@ -1702,7 +1702,7 @@ The `DirectedRelationshipIndexScan` operator examines all values stored in an in ---- PROFILE MATCH ()-[r: WORKS_IN]->() -WHERE r.title IS NOT NULL + WHERE r.title IS NOT NULL RETURN r ---- @@ -1745,7 +1745,7 @@ It allows the index to be partitioned into different segments where each segment CYPHER runtime=parallel PROFILE MATCH ()-[r: WORKS_IN]->() -WHERE r.title IS NOT NULL + WHERE r.title IS NOT NULL RETURN r ---- @@ -1787,7 +1787,7 @@ The `UndirectedRelationshipIndexScan` operator examines all values stored in an ---- PROFILE MATCH ()-[r: WORKS_IN]-() -WHERE r.title IS NOT NULL + WHERE r.title IS NOT NULL RETURN r ---- @@ -1830,7 +1830,7 @@ It allows the index to be partitioned into different segments where each segment CYPHER runtime=parallel PROFILE MATCH ()-[r: WORKS_IN]-() -WHERE r.title IS NOT NULL + WHERE r.title IS NOT NULL RETURN r ---- @@ -1881,7 +1881,7 @@ Although this is slower than an index seek (since all entries need to be examine ---- PROFILE MATCH ()-[r: WORKS_IN]->() -WHERE r.title CONTAINS 'senior' + WHERE r.title CONTAINS 'senior' RETURN r ---- @@ -1925,7 +1925,7 @@ Although this is slower than an index seek (since all entries need to be examine ---- PROFILE MATCH ()-[r: WORKS_IN]-() -WHERE r.title CONTAINS 'senior' + WHERE r.title CONTAINS 'senior' RETURN r ---- @@ -1969,7 +1969,7 @@ Although this is slower than an index seek (since all entries need to be examine ---- PROFILE MATCH ()-[r: WORKS_IN]->() -WHERE r.title ENDS WITH 'developer' + WHERE r.title ENDS WITH 'developer' RETURN r ---- @@ -2013,7 +2013,7 @@ Although this is slower than an index seek (since all entries need to be examine ---- PROFILE MATCH ()-[r: WORKS_IN]-() -WHERE r.title ENDS WITH 'developer' + WHERE r.title ENDS WITH 'developer' RETURN r ---- @@ -2057,7 +2057,7 @@ The relationship variable and the index used are shown in the arguments of the o ---- PROFILE MATCH (candidate)-[r:WORKS_IN]->() -WHERE r.title = 'chief architect' + WHERE r.title = 'chief architect' RETURN candidate ---- @@ -2100,7 +2100,7 @@ It allows the index to be partitioned into different segments where each segment CYPHER runtime=parallel PROFILE MATCH (candidate)-[r:WORKS_IN]->() -WHERE r.title = 'chief architect' + WHERE r.title = 'chief architect' RETURN candidate ---- @@ -2144,7 +2144,7 @@ The relationship variable and the index used are shown in the arguments of the o ---- PROFILE MATCH (candidate)-[r:WORKS_IN]-() -WHERE r.title = 'chief architect' + WHERE r.title = 'chief architect' RETURN candidate ---- @@ -2188,7 +2188,7 @@ The relationship variable and the index used are shown in the arguments of the o CYPHER runtime=parallel PROFILE MATCH (candidate)-[r:WORKS_IN]-() -WHERE r.title = 'chief architect' + WHERE r.title = 'chief architect' RETURN candidate ---- @@ -2231,7 +2231,7 @@ The `DirectedRelationshipByElementIdSeek` operator reads one or more relationshi ---- PROFILE MATCH (n1)-[r]->() -WHERE elementId(r) = 0 + WHERE elementId(r) = 0 RETURN r, n1 ---- @@ -2273,7 +2273,7 @@ The `DirectedRelationshipByIdSeek` operator reads one or more relationships by i ---- PROFILE MATCH (n1)-[r]->() -WHERE id(r) = 0 + WHERE id(r) = 0 RETURN r, n1 ---- @@ -2316,7 +2316,7 @@ As the direction is unspecified, two rows are produced for each relationship as ---- PROFILE MATCH (n1)-[r]-() -WHERE elementId(r) = 1 + WHERE elementId(r) = 1 RETURN r, n1 ---- @@ -2359,7 +2359,7 @@ As the direction is unspecified, two rows are produced for each relationship as ---- PROFILE MATCH (n1)-[r]-() -WHERE id(r) = 1 + WHERE id(r) = 1 RETURN r, n1 ---- @@ -2410,7 +2410,7 @@ The `DirectedRelationshipIndexSeekByRange` operator finds relationships and thei ---- PROFILE MATCH (candidate: Person)-[r:WORKS_IN]->(location) -WHERE r.duration > 100 + WHERE r.duration > 100 RETURN candidate ---- @@ -2455,7 +2455,7 @@ It allows the index to be partitioned into different segments where each segment CYPHER runtime=parallel PROFILE MATCH (candidate: Person)-[r:WORKS_IN]->(location) -WHERE r.duration > 100 + WHERE r.duration > 100 RETURN candidate ---- @@ -2501,7 +2501,7 @@ The `UndirectedRelationshipIndexSeekByRange` operator finds relationships and th ---- PROFILE MATCH (candidate: Person)-[r:WORKS_IN]-(location) -WHERE r.duration > 100 + WHERE r.duration > 100 RETURN candidate ---- @@ -2546,7 +2546,7 @@ It allows the store to be partitioned into different segments where each segment CYPHER runtime=parallel PROFILE MATCH (candidate: Person)-[r:WORKS_IN]-(location) -WHERE r.duration > 100 + WHERE r.duration > 100 RETURN candidate ---- @@ -2649,7 +2649,7 @@ This makes `SemiApply` a filtering operator, used mostly for pattern predicates PROFILE CYPHER runtime=slotted MATCH (p:Person) -WHERE (p)-[:FRIENDS_WITH]->(:Person) + WHERE (p)-[:FRIENDS_WITH]->(:Person) RETURN p.name ---- @@ -2705,7 +2705,7 @@ CYPHER runtime=slotted MATCH (me:Person {name: 'me'}), (other:Person) -WHERE NOT (me)-[:FRIENDS_WITH]->(other) + WHERE NOT (me)-[:FRIENDS_WITH]->(other) RETURN other.name ---- @@ -2763,7 +2763,7 @@ In the example, `LetSemiApply` will be used to check for the presence of the `FR PROFILE CYPHER runtime=slotted MATCH (other:Person) -WHERE (other)-[:FRIENDS_WITH]->(:Person) OR (other)-[:WORKS_IN]->(:Location) + WHERE (other)-[:FRIENDS_WITH]->(:Person) OR (other)-[:WORKS_IN]->(:Location) RETURN other.name ---- @@ -2826,7 +2826,7 @@ In the example, `LetAntiSemiApply` will be used to check for the absence of the PROFILE CYPHER runtime=slotted MATCH (other:Person) -WHERE NOT ((other)-[:FRIENDS_WITH]->(:Person)) OR (other)-[:WORKS_IN]->(:Location) + WHERE NOT ((other)-[:FRIENDS_WITH]->(:Person)) OR (other)-[:WORKS_IN]->(:Location) RETURN other.name ---- @@ -2887,7 +2887,7 @@ First, the normal expression predicate is evaluated, and, only if it returns `fa ---- PROFILE MATCH (other:Person) -WHERE other.age > 25 OR (other)-[:FRIENDS_WITH]->(:Person) + WHERE other.age > 25 OR (other)-[:FRIENDS_WITH]->(:Person) RETURN other.name ---- @@ -2944,7 +2944,7 @@ If the predicate returns `false` or `null`, `SelectOrAntiSemiApply` will instead ---- PROFILE MATCH (other:Person) -WHERE other.age > 25 OR NOT (other)-[:FRIENDS_WITH]->(:Person) + WHERE other.age > 25 OR NOT (other)-[:FRIENDS_WITH]->(:Person) RETURN other.name ---- @@ -3003,7 +3003,7 @@ This is a variation of the xref::planning-and-tuning/operators/operators-detail. PROFILE CYPHER runtime=slotted MATCH (other:Person) -WHERE (other)-[:FRIENDS_WITH]->(:Person) OR (other)-[:WORKS_IN]->(:Location) OR other.age = 5 + WHERE (other)-[:FRIENDS_WITH]->(:Person) OR (other)-[:WORKS_IN]->(:Location) OR other.age = 5 RETURN other.name ---- @@ -3064,7 +3064,7 @@ This operator is a variation of the xref::planning-and-tuning/operators/operator PROFILE CYPHER runtime=slotted MATCH (other:Person) -WHERE NOT (other)-[:FRIENDS_WITH]->(:Person) OR (other)-[:WORKS_IN]->(:Location) OR other.age = 5 + WHERE NOT (other)-[:FRIENDS_WITH]->(:Person) OR (other)-[:WORKS_IN]->(:Location) OR other.age = 5 RETURN other.name ---- @@ -3458,7 +3458,7 @@ PROFILE MATCH (p:Person), (q:Person) -WHERE p.age = q.age + WHERE p.age = q.age RETURN p, q ---- @@ -3576,7 +3576,7 @@ CYPHER runtime=pipelined MATCH (me:Person {name: 'me'}), (other:Person) -WHERE NOT (me)-[:FRIENDS_WITH]->(other) + WHERE NOT (me)-[:FRIENDS_WITH]->(other) RETURN other.name ---- @@ -4366,7 +4366,7 @@ The example finds the names of all friends of my friends that are not already my PROFILE CYPHER runtime=slotted MATCH (me:Person)-[:FRIENDS_WITH]-()-[:FRIENDS_WITH]-(other) -WHERE NOT (me)-[:FRIENDS_WITH]-(other) + WHERE NOT (me)-[:FRIENDS_WITH]-(other) RETURN other.name ---- @@ -4423,7 +4423,7 @@ The example finds the names of all friends of my friends that are not already my PROFILE CYPHER runtime=pipelined MATCH (me:Person)-[:FRIENDS_WITH]-()-[:FRIENDS_WITH]-(other) -WHERE NOT (me)-[:FRIENDS_WITH]-(other) + WHERE NOT (me)-[:FRIENDS_WITH]-(other) RETURN other.name ---- @@ -4486,7 +4486,7 @@ The example finds the names of all friends of my friends that are not already my PROFILE CYPHER runtime=pipelined MATCH (me:Person)-[:FRIENDS_WITH]-()-[:FRIENDS_WITH]-(other) -WHERE NOT (me)-[:FRIENDS_WITH]-(other) + WHERE NOT (me)-[:FRIENDS_WITH]-(other) RETURN other.name ---- @@ -4667,7 +4667,7 @@ This operator uses lazy evaluation and has a lower memory pressure in the system ---- PROFILE MATCH (p:Person) -WHERE p.name STARTS WITH 'P' + WHERE p.name STARTS WITH 'P' RETURN p.name, count(*) AS count ---- @@ -4890,7 +4890,7 @@ The `Filter` operator filters each row coming from the child operator, only pass ---- PROFILE MATCH (p:Person) -WHERE p.name =~ '^a.*' + WHERE p.name =~ '^a.*' RETURN p ---- @@ -5180,7 +5180,7 @@ This operator has a lower memory pressure in the system than the `Distinct` oper ---- PROFILE MATCH (p:Person) -WHERE p.name STARTS WITH 'P' + WHERE p.name STARTS WITH 'P' RETURN DISTINCT p.name ---- @@ -5224,7 +5224,7 @@ The `ProcedureCall` operator indicates an invocation to a procedure. PROFILE CALL db.labels() YIELD label RETURN * -ORDER BY label + ORDER BY label ---- .Query Plan @@ -5357,7 +5357,7 @@ In order to sort the data, all data from the source operator needs to be pulled PROFILE MATCH (p:Person) RETURN p -ORDER BY p.name + ORDER BY p.name ---- .Query Plan @@ -5404,9 +5404,9 @@ Partial sort is only applicable when sorting on multiple columns. ---- PROFILE MATCH (p:Person) -WHERE p.name STARTS WITH 'P' + WHERE p.name STARTS WITH 'P' RETURN p -ORDER BY p.name, p.age + ORDER BY p.name, p.age ---- .Query Plan @@ -5453,8 +5453,8 @@ Instead of sorting the entire input, only the top `+n+` rows are retained. PROFILE MATCH (p:Person) RETURN p -ORDER BY p.name -LIMIT 2 + ORDER BY p.name + LIMIT 2 ---- .Query Plan @@ -5502,10 +5502,10 @@ Partial top is only applicable when sorting on multiple columns. ---- PROFILE MATCH (p:Person) -WHERE p.name STARTS WITH 'P' + WHERE p.name STARTS WITH 'P' RETURN p -ORDER BY p.name, p.age -LIMIT 2 + ORDER BY p.name, p.age + LIMIT 2 ---- .Query Plan @@ -5550,7 +5550,7 @@ The `Limit` operator returns the first `+n+` rows from the incoming input. PROFILE MATCH (p:Person) RETURN p -LIMIT 3 + LIMIT 3 ---- .Query Plan @@ -5597,7 +5597,7 @@ PROFILE MATCH (p:Person) SET p.seen = true RETURN p -LIMIT 3 + LIMIT 3 ---- .Query Plan @@ -5642,8 +5642,8 @@ The `Skip` operator skips `+n+` rows from the incoming rows. PROFILE MATCH (p:Person) RETURN p -ORDER BY p.id -SKIP 1 + ORDER BY p.id + SKIP 1 ---- .Query Plan diff --git a/modules/ROOT/pages/queries/basic.adoc b/modules/ROOT/pages/queries/basic.adoc index cb8c89698..3af9aa06a 100644 --- a/modules/ROOT/pages/queries/basic.adoc +++ b/modules/ROOT/pages/queries/basic.adoc @@ -575,7 +575,7 @@ This query matches all nodes with the `Person` label, and limits the results to ---- MATCH (people:Person) RETURN people -LIMIT 5 + LIMIT 5 ---- .Result @@ -613,9 +613,9 @@ The final clause returns the result in a descending chronological order. [source, cypher] ---- MATCH (bornInEighties:Person) -WHERE bornInEighties.born >= 1980 AND bornInEighties.born < 1990 + bornInEighties.born >= 1980 AND bornInEighties.born < 1990 RETURN bornInEighties.name as name, bornInEighties.born as born -ORDER BY born DESC + ORDER BY born DESC ---- .Result @@ -750,8 +750,8 @@ The ``DISTINCT` operator ensures that the result contain no duplicate values. ---- MATCH (tom:Person {name:'Tom Hanks'})--{2}(colleagues:Person) RETURN DISTINCT colleagues.name AS name, colleagues.born AS bornIn -ORDER BY bornIn -LIMIT 5 + ORDER BY bornIn + LIMIT 5 ---- .Result @@ -776,8 +776,8 @@ The below query matches all `Person` nodes between `1` and `4` hops away from `T ---- MATCH (p:Person {name:'Tom Hanks'})--{1,4}(colleagues:Person) RETURN DISTINCT colleagues.name AS name, colleagues.born AS bornIn -ORDER BY bornIn, name -LIMIT 5 + ORDER BY bornIn, name + LIMIT 5 ---- .Result @@ -845,10 +845,10 @@ The query then orders the results by how frequently a matched co-co-actor has co ---- MATCH (keanu:Person {name:'Keanu Reeves'})-[:ACTED_IN]->(m:Movie)<-[:ACTED_IN]-(coActors:Person), (coActors:Person)-[:ACTED_IN]->(m2:Movie)<-[:ACTED_IN]-(cocoActors:Person) -WHERE NOT (keanu)-[:ACTED_IN]->()<-[:ACTED_IN]-(cocoActors) AND keanu <> cocoActors + WHERE NOT (keanu)-[:ACTED_IN]->()<-[:ACTED_IN]-(cocoActors) AND keanu <> cocoActors RETURN cocoActors.name AS recommended, count(cocoActors) AS strength -ORDER BY strength DESC -LIMIT 7 + ORDER BY strength DESC + LIMIT 7 ---- .Result diff --git a/modules/ROOT/pages/queries/composed-queries/combined-queries.adoc b/modules/ROOT/pages/queries/composed-queries/combined-queries.adoc index 7cefcc66f..61f9a2116 100644 --- a/modules/ROOT/pages/queries/composed-queries/combined-queries.adoc +++ b/modules/ROOT/pages/queries/composed-queries/combined-queries.adoc @@ -148,7 +148,7 @@ UNION ALL RETURN m.title AS name } RETURN name, count(*) AS count -ORDER BY count + ORDER BY count ---- // end::combined_queries_post_union_processing[] diff --git a/modules/ROOT/pages/queries/composed-queries/conditional-queries.adoc b/modules/ROOT/pages/queries/composed-queries/conditional-queries.adoc index ad42adf29..4888ddbaa 100644 --- a/modules/ROOT/pages/queries/composed-queries/conditional-queries.adoc +++ b/modules/ROOT/pages/queries/composed-queries/conditional-queries.adoc @@ -78,7 +78,8 @@ Since the second `WHEN` branch is `true`, it will execute, while the preceding b [source, cypher] ---- WHEN true THEN { - MATCH (n:Person) WHERE n.name STARTS WITH "A" + MATCH (n:Person) + WHERE n.name STARTS WITH "A" RETURN n.name AS name } ELSE { @@ -284,14 +285,14 @@ Unlike `CALL` subqueries, variables returned in an `EXISTS` subquery are not ava [source, cypher] ---- MATCH (n:Person) -WHERE EXISTS { - WHEN n.age > 40 THEN { + WHERE EXISTS { + WHEN n.age > 40 THEN { RETURN n.name AS x - } - ELSE { + } + ELSE { MATCH (n)-[:LOVES]->(x:Person) RETURN x - } + } } RETURN n.name AS name, n.age AS age diff --git a/modules/ROOT/pages/styleguide.adoc b/modules/ROOT/pages/styleguide.adoc index bff296f2e..472c90929 100644 --- a/modules/ROOT/pages/styleguide.adoc +++ b/modules/ROOT/pages/styleguide.adoc @@ -27,14 +27,31 @@ For example: `toString()`. .Bad [source, cypher] ---- -MATCH (n) WHERE n.name CONTAINS 's' RETURN n.name +MATCH (n) RETURN n.name ---- .Good [source, cypher] ---- MATCH (n) -WHERE n.name CONTAINS 's' +RETURN n.name +---- + +* Indent the subclauses `WHERE`, `LIMIT`, `ORDER BY`, and `SKIP` with two spaces. + +.Bad +[source, cypher] +---- +MATCH (n) +WHERE n.name = 'Keanu' +RETURN n.name +---- + +.Good +[source, cypher] +---- +MATCH (n) + WHERE n.name = 'Keanu' RETURN n.name ---- @@ -69,7 +86,7 @@ Leave the closing brace on its own line. [source, cypher] ---- MATCH (a:A) -WHERE + WHERE EXISTS { MATCH (a)-->(b:B) WHERE b.prop = 'yellow' } RETURN a.foo ---- @@ -78,9 +95,9 @@ RETURN a.foo [source, cypher] ---- MATCH (a:A) -WHERE EXISTS + WHERE EXISTS {MATCH (a)-->(b:B) -WHERE b.prop = 'yellow'} + WHERE b.prop = 'yellow'} RETURN a.foo ---- @@ -90,7 +107,7 @@ RETURN a.foo MATCH (a:A) WHERE EXISTS { MATCH (a)-->(b:B) - WHERE b.prop = 'yellow' + WHERE b.prop = 'yellow' } RETURN a.foo ---- @@ -101,7 +118,7 @@ RETURN a.foo [source, cypher] ---- MATCH (a:A) -WHERE EXISTS { + WHERE EXISTS { (a)-->(b:B) } RETURN a.prop @@ -111,7 +128,7 @@ RETURN a.prop [source, cypher] ---- MATCH (a:A) -WHERE EXISTS { (a)-->(b:B) } + WHERE EXISTS { (a)-->(b:B) } RETURN a.prop ---- @@ -132,7 +149,7 @@ return p.name [source, cypher] ---- MATCH (p:Person) -WHERE p.name STARTS WITH 'Ma' + WHERE p.name STARTS WITH 'Ma' RETURN p.name ---- @@ -262,7 +279,7 @@ RETURN length(p) [source, cypher] ---- MATCH p = (s)-->(e) -WHERE s.name <> e.name + WHERE s.name <> e.name RETURN length(p) ---- @@ -320,7 +337,7 @@ RETURN split('original', 'i') [source, cypher] ---- MATCH (a:A) -WHERE EXISTS {(a)-->(b:B)} + WHERE EXISTS {(a)-->(b:B)} RETURN a.prop ---- @@ -328,7 +345,7 @@ RETURN a.prop [source, cypher] ---- MATCH (a:A) -WHERE EXISTS { (a)-->(b:B) } + WHERE EXISTS { (a)-->(b:B) } RETURN a.prop ---- @@ -392,7 +409,7 @@ RETURN count(vehicle) [source, cypher] ---- MATCH ()-->(vehicle:Car)-->(manufacturer:Company) -WHERE manufacturer.foundedYear < 2000 + WHERE manufacturer.foundedYear < 2000 RETURN vehicle.mileage ---- @@ -400,7 +417,7 @@ RETURN vehicle.mileage [source, cypher] ---- MATCH (manufacturer:Company)<--(vehicle:Car)<--() -WHERE manufacturer.foundedYear < 2000 + WHERE manufacturer.foundedYear < 2000 RETURN vehicle.mileage ---- @@ -410,7 +427,7 @@ RETURN vehicle.mileage [source, cypher] ---- MATCH (:Person)-->(vehicle:Car)-->(manufacturer:Company) -WHERE manufacturer.foundedYear < 2000 + WHERE manufacturer.foundedYear < 2000 RETURN vehicle.mileage ---- @@ -418,7 +435,7 @@ RETURN vehicle.mileage [source, cypher] ---- MATCH (manufacturer:Company)<--(vehicle:Car)<--(:Person) -WHERE manufacturer.foundedYear < 2000 + WHERE manufacturer.foundedYear < 2000 RETURN vehicle.mileage ---- diff --git a/modules/ROOT/pages/subqueries/call-subquery.adoc b/modules/ROOT/pages/subqueries/call-subquery.adoc index 36484bbfe..0f10c8785 100644 --- a/modules/ROOT/pages/subqueries/call-subquery.adoc +++ b/modules/ROOT/pages/subqueries/call-subquery.adoc @@ -185,8 +185,8 @@ CALL (p) { RETURN p.name AS playerName, p.rating AS rating } RETURN playerName, rating, t AS team -ORDER BY rating -LIMIT 1 + ORDER BY rating + LIMIT 1 ---- .Result @@ -225,7 +225,7 @@ RETURN p.name AS playerName, p.lastUpdated AS playerUpdated, t.name AS teamName, t.lastUpdated AS teamUpdated -LIMIT 1 + LIMIT 1 ---- .Result @@ -378,7 +378,7 @@ For example, the following query using a `WHERE` clause after an importing `WITH UNWIND [[1,2],[1,2,3,4],[1,2,3,4,5]] AS l CALL { WITH l - WHERE size(l) > 2 + WHERE size(l) > 2 RETURN l AS largeLists } RETURN largeLists @@ -402,7 +402,7 @@ UNWIND [[1,2],[1,2,3,4],[1,2,3,4,5]] AS l CALL { WITH l WITH l - WHERE size(l) > 2 + WHERE size(l) > 2 RETURN l AS largeLists } RETURN largeLists @@ -557,12 +557,12 @@ The `CALL` clause is relying on the incoming row ordering to ensure that a corre ---- MATCH (player:Player) WITH player -ORDER BY player.age ASC LIMIT 1 - SET player:ListHead + ORDER BY player.age ASC LIMIT 1 +SET player:ListHead WITH * MATCH (nextPlayer: Player&!ListHead) WITH nextPlayer -ORDER BY nextPlayer.age + ORDER BY nextPlayer.age CALL (nextPlayer) { MATCH (current:ListHead) REMOVE current:ListHead @@ -631,13 +631,13 @@ This example query finds the youngest and the oldest `Player` in the graph. CALL () { MATCH (p:Player) RETURN p - ORDER BY p.age ASC - LIMIT 1 + ORDER BY p.age ASC + LIMIT 1 UNION MATCH (p:Player) RETURN p - ORDER BY p.age DESC - LIMIT 1 + ORDER BY p.age DESC + LIMIT 1 } RETURN p.name AS playerName, p.age AS age ---- @@ -667,7 +667,7 @@ CALL (t) { RETURN o.dollars AS moneyOwed } RETURN t.name AS team, sum(moneyOwed) AS amountOwed -ORDER BY amountOwed DESC + ORDER BY amountOwed DESC ---- .Result diff --git a/modules/ROOT/pages/subqueries/collect.adoc b/modules/ROOT/pages/subqueries/collect.adoc index 714ec9298..6d0110ed8 100644 --- a/modules/ROOT/pages/subqueries/collect.adoc +++ b/modules/ROOT/pages/subqueries/collect.adoc @@ -37,7 +37,7 @@ The following query exemplifies this and outputs the owners of the dog named `Oz [source, cypher] ---- MATCH (person:Person) -WHERE 'Ozzy' IN COLLECT { MATCH (person)-[:HAS_DOG]->(dog:Dog) RETURN dog.name } + WHERE 'Ozzy' IN COLLECT { MATCH (person)-[:HAS_DOG]->(dog:Dog) RETURN dog.name } RETURN person.name AS name ---- @@ -58,11 +58,12 @@ Variables introduced by the `MATCH` clause and the outside scope can be used in [source, cypher] ---- MATCH (person:Person) -RETURN person.name as name, COLLECT { - MATCH (person)-[r:HAS_DOG]->(dog:Dog) - WHERE r.since > 2017 - RETURN dog.name -} as youngDogs +RETURN person.name as name, + COLLECT { + MATCH (person)-[r:HAS_DOG]->(dog:Dog) + WHERE r.since > 2017 + RETURN dog.name + } AS youngDogs ---- [role="queryresult",options="header,footer",cols="2*(dog:Dog) - RETURN dog.name AS petName - UNION - MATCH (person)-[:HAS_CAT]->(cat:Cat) - RETURN cat.name AS petName - } AS petNames +RETURN person.name AS name, + COLLECT { + MATCH (person)-[:HAS_DOG]->(dog:Dog) + RETURN dog.name AS petName + UNION + MATCH (person)-[:HAS_CAT]->(cat:Cat) + RETURN cat.name AS petName + } AS petNames ---- [role="queryresult",options="header,footer",cols="2*(d:Dog {name: name}) - RETURN d.name -} as dogsOfTheYear + WITH 'Ozzy' AS name + MATCH (person)-[r:HAS_DOG]->(d:Dog {name: name}) + RETURN d.name + } AS dogsOfTheYear ---- .Error message @@ -172,12 +172,13 @@ Note that the outer scope variable `person` referenced in the main query is stil [source, cypher] ---- MATCH (person:Person) -RETURN person.name AS name, COLLECT { - WITH 2018 AS yearOfTheDog - MATCH (person)-[r:HAS_DOG]->(d:Dog) - WHERE r.since = yearOfTheDog - RETURN d.name -} as dogsOfTheYear +RETURN person.name AS name, + COLLECT { + WITH 2018 AS yearOfTheDog + MATCH (person)-[r:HAS_DOG]->(d:Dog) + WHERE r.since = yearOfTheDog + RETURN d.name + } AS dogsOfTheYear ---- [role="queryresult",options="header,footer",cols="2*(d:Dog) - MATCH (d)-[:HAS_TOY]->(t:Toy) - RETURN t.name - } as toyNames + MATCH (person)-[:HAS_DOG]->(d:Dog) + MATCH (d)-[:HAS_TOY]->(t:Toy) + RETURN t.name + } AS toyNames ---- [role="queryresult",options="header,footer",cols="2*(d:Dog) RETURN d.name } -RETURN person.dogNames as dogNames +RETURN person.dogNames AS dogNames ---- [role="queryresult",options="header,footer",cols="1*(d:Dog) RETURN d.name } AS dogNames, +RETURN COLLECT { + MATCH (person)-[:HAS_DOG]->(d:Dog) + RETURN d.name + } AS dogNames, avg(person.age) AS averageAge - ORDER BY dogNames + ORDER BY dogNames ---- [role="queryresult",options="header,footer",cols="2*(:Dog) } > 1 + WHERE COUNT { (person)-[:HAS_DOG]->(:Dog) } > 1 RETURN person.name AS name ---- @@ -57,10 +57,10 @@ Variables introduced by the `MATCH` clause and the outside scope can be used in [source, cypher] ---- MATCH (person:Person) -WHERE COUNT { + WHERE COUNT { (person)-[:HAS_DOG]->(dog:Dog) - WHERE person.name = dog.name -} = 1 + WHERE person.name = dog.name + } = 1 RETURN person.name AS name ---- @@ -125,11 +125,11 @@ MATCH (person:Person) RETURN person.name AS name, COUNT { - MATCH (person)-[:HAS_DOG]->(dog:Dog) - RETURN dog.name AS petName - UNION - MATCH (person)-[:HAS_CAT]->(cat:Cat) - RETURN cat.name AS petName + MATCH (person)-[:HAS_DOG]->(dog:Dog) + RETURN dog.name AS petName + UNION + MATCH (person)-[:HAS_CAT]->(cat:Cat) + RETURN cat.name AS petName } AS numPets ---- @@ -155,11 +155,11 @@ In the example below, the outer variable `name` is shadowed and will therefore t ---- WITH 'Peter' as name MATCH (person:Person {name: name}) -WHERE COUNT { + WHERE COUNT { WITH "Ozzy" AS name MATCH (person)-[:HAS_DOG]->(d:Dog) - WHERE d.name = name -} = 1 + WHERE d.name = name + } = 1 RETURN person.name AS name ---- @@ -176,11 +176,11 @@ Note that the outer scope variable `person` referenced in the main query is stil [source, cypher] ---- MATCH (person:Person) -WHERE COUNT { + WHERE COUNT { WITH "Ozzy" AS dogName MATCH (person)-[:HAS_DOG]->(d:Dog) - WHERE d.name = dogName -} = 1 + WHERE d.name = dogName + } = 1 RETURN person.name AS name ---- @@ -205,8 +205,8 @@ See a few examples below: [source, cypher] ---- MATCH (person:Person) -RETURN person.name, COUNT { (person)-[:HAS_DOG]->(:Dog) } as howManyDogs - +RETURN person.name, + COUNT { (person)-[:HAS_DOG]->(:Dog) } AS howManyDogs ---- [role="queryresult",options="header,footer",cols="2*(:Dog) } as howManyDogs [source, cypher] ---- -MATCH (person:Person) WHERE person.name ="Andy" +MATCH (person:Person) + WHERE person.name ="Andy" SET person.howManyDogs = COUNT { (person)-[:HAS_DOG]->(:Dog) } RETURN person.howManyDogs as howManyDogs - ---- [role="queryresult",options="header,footer",cols="1*(:Dog) } > 1 THEN "Doglover " + person.name ELSE person.name END AS result - ---- [role="queryresult",options="header,footer",cols="1*(:Dog) } AS numDogs, avg(person.age) AS averageAge - ORDER BY numDogs - + ORDER BY numDogs ---- [role="queryresult",options="header,footer",cols="2*(:Dog) RETURN person.name -} = 1 + } = 1 RETURN person.name AS name ---- diff --git a/modules/ROOT/pages/subqueries/existential.adoc b/modules/ROOT/pages/subqueries/existential.adoc index e0132177e..58c3ff88f 100644 --- a/modules/ROOT/pages/subqueries/existential.adoc +++ b/modules/ROOT/pages/subqueries/existential.adoc @@ -36,9 +36,9 @@ The following example shows this: [source, cypher] ---- MATCH (person:Person) -WHERE EXISTS { + WHERE EXISTS { (person)-[:HAS_DOG]->(:Dog) -} + } RETURN person.name AS name ---- @@ -59,10 +59,10 @@ Variables introduced by the `MATCH` clause and the outside scope can be used in [source, cypher] ---- MATCH (person:Person) -WHERE EXISTS { + WHERE EXISTS { MATCH (person)-[:HAS_DOG]->(dog:Dog) - WHERE person.name = dog.name -} + WHERE person.name = dog.name + } RETURN person.name AS name ---- @@ -89,16 +89,16 @@ Note that `Peter`, being 35 and a dog owner, is excluded from the result. [source, cypher] ---- MATCH (n:Person) -WHERE EXISTS { - WHEN n.age > 35 THEN { + WHERE EXISTS { + WHEN n.age > 35 THEN { MATCH (n)-[:HAS_DOG]->(:Dog) RETURN n AS petOwner - } - ELSE { + } + ELSE { MATCH (n)-[:HAS_CAT]->(:Cat) RETURN n AS petOwner + } } -} RETURN n.name AS name, n.age AS age ---- @@ -125,13 +125,13 @@ That means that it is possible to access all variables from inside the subquery [source, cypher] ---- MATCH (person:Person) -WHERE EXISTS { - MATCH (person)-[:HAS_DOG]->(dog:Dog) WHERE EXISTS { - MATCH (dog)-[:HAS_TOY]->(toy:Toy) - WHERE toy.name = 'Banana' + MATCH (person)-[:HAS_DOG]->(dog:Dog) + WHERE EXISTS { + MATCH (dog)-[:HAS_TOY]->(toy:Toy) + WHERE toy.name = 'Banana' + } } -} RETURN person.name AS name ---- @@ -152,9 +152,10 @@ Here the result is a boolean that shows whether the subquery can find the given [source, cypher] ---- MATCH (person:Person) -RETURN person.name AS name, EXISTS { - MATCH (person)-[:HAS_DOG]->(:Dog) -} AS hasDog +RETURN person.name AS name, + EXISTS { + MATCH (person)-[:HAS_DOG]->(:Dog) + } AS hasDog ---- [role="queryresult",options="header,footer",cols="2*(d:Dog) - WHERE d.name = name -} + WHERE d.name = name + } RETURN person.name AS name ---- @@ -229,11 +230,11 @@ Note that the outer scope variable `person` referenced in the main query is stil [source, cypher] ---- MATCH (person:Person) -WHERE EXISTS { + WHERE EXISTS { WITH "Ozzy" AS dogName MATCH (person)-[:HAS_DOG]->(d:Dog) - WHERE d.name = dogName -} + WHERE d.name = dogName + } RETURN person.name AS name ---- @@ -255,10 +256,10 @@ Any variables returned in an `EXISTS` subquery will not be available after the s [source, cypher] ---- MATCH (person:Person) -WHERE EXISTS { + WHERE EXISTS { MATCH (person)-[:HAS_DOG]->(:Dog) RETURN person.name -} + } RETURN person.name AS name ---- diff --git a/modules/ROOT/pages/subqueries/subqueries-in-transactions.adoc b/modules/ROOT/pages/subqueries/subqueries-in-transactions.adoc index bd3ece49d..229075bc4 100644 --- a/modules/ROOT/pages/subqueries/subqueries-in-transactions.adoc +++ b/modules/ROOT/pages/subqueries/subqueries-in-transactions.adoc @@ -112,7 +112,8 @@ Any necessary filtering can be done before the subquery. .Query [source, cypher] ---- -MATCH (n:Label) WHERE n.prop > 100 +MATCH (n:Label) + WHERE n.prop > 100 CALL (n) { DETACH DELETE n } IN TRANSACTIONS @@ -267,7 +268,7 @@ CALL { USE graph.byName( graphName ) WITH id MATCH (n) - WHERE elementId(n) = id + WHERE elementId(n) = id DETACH DELETE n } IN TRANSACTIONS ---- @@ -898,7 +899,7 @@ CALL (row) { MERGE (m)-[r:RELEASED_IN]->(y) } IN 2 CONCURRENT TRANSACTIONS OF 10 ROWS ON ERROR CONTINUE REPORT STATUS as status WITH status -WHERE status.errorMessage IS NOT NULL + WHERE status.errorMessage IS NOT NULL RETURN status.transactionId AS transaction, status.committed AS commitStatus, status.errorMessage AS errorMessage ---- diff --git a/modules/ROOT/pages/syntax/comments.adoc b/modules/ROOT/pages/syntax/comments.adoc index 138654aef..52a4c2ed0 100644 --- a/modules/ROOT/pages/syntax/comments.adoc +++ b/modules/ROOT/pages/syntax/comments.adoc @@ -33,6 +33,7 @@ RETURN n [source, cypher, indent=0] ---- -MATCH (n) WHERE n.property = '//This is NOT a comment' RETURN n +MATCH (n) + WHERE n.property = '//This is NOT a comment' RETURN n ---- diff --git a/modules/ROOT/pages/syntax/parameters.adoc b/modules/ROOT/pages/syntax/parameters.adoc index f31186f4f..10ff58082 100644 --- a/modules/ROOT/pages/syntax/parameters.adoc +++ b/modules/ROOT/pages/syntax/parameters.adoc @@ -66,7 +66,7 @@ It is not recommended to rely on this behavior - users should rather use paramet [source,cypher] ---- MATCH (n:Person) -WHERE n.name = $name + n.name = $name RETURN n ---- @@ -103,7 +103,7 @@ RETURN n [source,cypher] ---- MATCH (n:Person) -WHERE n.name =~ $regex + WHERE n.name =~ $regex RETURN n.name ---- @@ -123,7 +123,7 @@ RETURN n.name [source,cypher] ---- MATCH (n:Person) -WHERE n.name STARTS WITH $name + WHERE n.name STARTS WITH $name RETURN n.name ---- @@ -198,7 +198,7 @@ Note that this will replace all the current properties. [source,cypher] ---- MATCH (n:Person) -WHERE n.name = 'Michaela' + WHERE n.name = 'Michaela' SET n = $props ---- @@ -220,8 +220,8 @@ SET n = $props ---- MATCH (n:Person) RETURN n.name -SKIP $s -LIMIT $l + SKIP $s + LIMIT $l ---- @@ -240,7 +240,7 @@ LIMIT $l [source,cypher] ---- MATCH (n) -WHERE elementId(n) = $id + WHERE elementId(n) = $id RETURN n.name ---- @@ -262,7 +262,7 @@ RETURN n.name [source,cypher] ---- MATCH (n) -WHERE elementId(n) IN $ids + WHERE elementId(n) IN $ids RETURN n.name ---- diff --git a/modules/ROOT/pages/syntax/parsing.adoc b/modules/ROOT/pages/syntax/parsing.adoc index 4f8c60a60..8aa454b23 100644 --- a/modules/ROOT/pages/syntax/parsing.adoc +++ b/modules/ROOT/pages/syntax/parsing.adoc @@ -17,7 +17,7 @@ For example, the below query uses the Unicode `u00B0` to search for any recipe d [source, cypher] ---- MATCH (r:Recipe) -WHERE r.description CONTAINS "\u00B0" + WHERE r.description CONTAINS "\u00B0" RETURN r ---- diff --git a/modules/ROOT/pages/values-and-types/ordering-equality-comparison.adoc b/modules/ROOT/pages/values-and-types/ordering-equality-comparison.adoc index 8cf95403d..fd861fabb 100644 --- a/modules/ROOT/pages/values-and-types/ordering-equality-comparison.adoc +++ b/modules/ROOT/pages/values-and-types/ordering-equality-comparison.adoc @@ -68,7 +68,7 @@ Values of different types are ordered based on a predefined hierarchy, from leas WITH [42, "hello", NULL, true, {name: "Alice"}, [1, 2, 3], date("2024-02-10")] AS v UNWIND v AS values RETURN values -ORDER BY values + ORDER BY values ---- .Result