Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions modules/ROOT/pages/clauses/filter.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ RETURN n.name AS name
|===

.Filter on a node property
// tag::clauses_filter_node_property[]
[source, cypher]
----
MATCH (n:Person)
FILTER n.age < 35
RETURN n.name AS name, n.age AS age
----
// end::clauses_filter_node_property[]

.Result
[role="queryresult",options="header,footer",cols="2*<m"]
Expand Down Expand Up @@ -105,12 +107,15 @@ To filter on a property using a dynamically computed name, use square brackets `
----

.Filter on a dynamically computed node property
// tag::clauses_filter_dynamic[]
[source, cypher]
----
MATCH (n:Person)
FILTER n[$propname] > 40
RETURN n.name AS name, n.age AS age
----
// end::clauses_filter_dynamic[]


.Result
[role="queryresult",options="header,footer",cols="2*<m"]
Expand Down Expand Up @@ -275,12 +280,15 @@ MERGE (c:Company {id: row.Id})
----

.`LOAD CSV` using `FILTER`
// tag::clauses_filter_load_csv[]
[source, cypher]
----
LOAD CSV WITH HEADERS FROM 'file:///companies.csv' AS row
FILTER row.Id IS NOT NULL
MERGE (c:Company {id: row.Id})
----
// end::clauses_filter_load_csv[]


=====

Expand Down
4 changes: 4 additions & 0 deletions modules/ROOT/pages/clauses/let.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ RETURN fullName
|===

.Using `LET` to bind several variables
// tag::clauses_let_bind_variables[]
[source, cypher]
----
MATCH (s:Supplier)-[:SUPPLIES]->(p:Product)
LET supplier = s.name, product = p.name
RETURN supplier, product
----
// end::clauses_let_bind_variables[]

.Result
[role="queryresult",options="header,footer", cols="2*<m"]
Expand Down Expand Up @@ -191,6 +193,7 @@ Specifically, the variable `isExpensive` is created in the first `LET` clause an
Note also that the variable `p`, bound in the `MATCH` clause, is available in the final `RETURN` clause despite not being referenced in any of `LET` clauses.

.`LET` referencing variables assigned in previous a `LET`
// tag::clauses_let_chain_expressions[]
[source, cypher]
----
MATCH (p:Product)
Expand All @@ -203,6 +206,7 @@ END
RETURN p.name AS product, p.price AS price, isAffordable, discountCategory
ORDER BY price
----
// end::clauses_let_chain_expressions[]

.Result
[role="queryresult",options="header,footer", cols="4*<m"]
Expand Down
16 changes: 8 additions & 8 deletions modules/ROOT/pages/functions/mathematical-trigonometric.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,12 @@ The cosine of `0.5` is returned.
======

.Query
// tag::functions_mathematical_trigonometric_cos[]
// tag::functions_mathematical_trigonometric_cosh[]
[source, cypher, indent=0]
----
RETURN cosh(0.7)
----
// end::functions_mathematical_trigonometric_cos[]
// end::functions_mathematical_trigonometric_cosh[]

The hyperbolic cosine of `0.7` is returned.

Expand Down Expand Up @@ -353,12 +353,12 @@ The cotangent of `0.5` is returned.
======

.Query
// tag::functions_mathematical_trigonometric_cot[]
// tag::functions_mathematical_trigonometric_coth[]
[source, cypher, indent=0]
----
RETURN coth(0.7)
----
// end::functions_mathematical_trigonometric_cot[]
// end::functions_mathematical_trigonometric_coth[]

The hyperbolic cotangent of `0.7` is returned.

Expand Down Expand Up @@ -654,12 +654,12 @@ The sine of `0.5` is returned.
======

.Query
// tag::functions_mathematical_trigonometric_sin[]
// tag::functions_mathematical_trigonometric_sinh[]
[source, cypher, indent=0]
----
RETURN sinh(0.7)
----
// end::functions_mathematical_trigonometric_sin[]
// end::functions_mathematical_trigonometric_sinh[]

The hyperbolic sine of `0.7` is returned.

Expand Down Expand Up @@ -748,12 +748,12 @@ The tangent of `0.5` is returned.
======

.Query
// tag::functions_mathematical_trigonometric_tan[]
// tag::functions_mathematical_trigonometric_tanh[]
[source, cypher, indent=0]
----
RETURN tanh(0.7)
----
// end::functions_mathematical_trigonometric_tan[]
// end::functions_mathematical_trigonometric_tanh[]

The hyperbolic tangent of `0.7` is returned.

Expand Down
4 changes: 2 additions & 2 deletions modules/ROOT/pages/functions/temporal/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1365,13 +1365,13 @@ RETURN dateTimeFromEpoch
======

.Query
// tag::functions_temporal_datetime_fromepochmillis
// tag::functions_temporal_datetime_fromepochmillis[]
[source, cypher]
----
WITH datetime.fromEpochMillis(1724198400000) AS dateTimeFromMillis
RETURN dateTimeFromMillis
----
// end::functions_temporal_datetime_fromepochmillis
// end::functions_temporal_datetime_fromepochmillis[]

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ To combine `UNION` (or `UNION DISTINCT`) and `UNION ALL` in the same query, encl
This allows the enclosed query to act as an argument that can be combined with an outer `UNION` operation of any type.

.Combine `UNION` and `UNION ALL`
// tag::combined_queries_top_level_braces[]
[source, cypher]
----
{
Expand All @@ -185,6 +186,7 @@ UNION ALL
MATCH (n:Movie)
RETURN n.title AS name
----
// end::combined_queries_top_level_braces[]

The combined result is returned.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ If no `WHEN` branches evaluates to `true` and no `ELSE` branch is present, no br
The following examples demonstrates this logic:

.Conditional logic
// tag::conditional_queries_logic[]
[source, cypher]
----
WHEN false THEN RETURN 1 AS x
WHEN true THEN RETURN 2 AS x
WHEN true THEN RETURN 3 AS x
ELSE RETURN 3 AS x
----
// end::conditional_queries_logic[]

Since the second `WHEN` branch is `true`, it will execute, while the preceding branch (which is `false`) and the succeeding `WHEN` branch (which is `true`) as well as the `ELSE` branch will be skipped.

Expand All @@ -72,6 +74,7 @@ Since the second `WHEN` branch is `true`, it will execute, while the preceding b
|===

.Conditionally executing queries in standalone `WHEN` branches
// tag::conditional_queries_standalone_when[]
[source, cypher]
----
WHEN true THEN {
Expand All @@ -83,6 +86,7 @@ ELSE {
RETURN n.name AS name
}
----
// end::conditional_queries_standalone_when[]

[NOTE]
The enclosing `{}` in the above example and the below examples are not required (unless explicitly stated), but they clarify the different conditional branches of the query.
Expand Down Expand Up @@ -169,6 +173,7 @@ Instead, if `WHEN` constructs are part of a larger query, they must either be pl
In this example, `WHEN` is used to execute a xref:subqueries/call-subquery.adoc[`CALL` subquery] for each row that the condition (`manager IS NULL`) evaluates to `true`.

.Conditional `CALL` subquery
// tag::conditional_queries_call[]
[source, cypher]
----
MATCH (n:Person)
Expand All @@ -183,6 +188,7 @@ CALL (*) {
RETURN newManager.name AS newManager,
collect(employee) AS employees
----
// end::conditional_queries_call[]

Because only `Daniel` and `Eskil` had no outgoing `WORKS_FOR` relationships, they have now been connected as employees of the new `Peter` node.

Expand Down Expand Up @@ -274,6 +280,7 @@ In this example, `WHEN` is used inside an `EXISTS` subquery to conditionally exe
Unlike `CALL` subqueries, variables returned in an `EXISTS` subquery are not available to the outer scope (the same is true for `COUNT` and `COLLECT` subqueries).

.`WHEN` inside an `EXISTS` subquery
// tag::conditional_queries_exists[]
[source, cypher]
----
MATCH (n:Person)
Expand All @@ -289,6 +296,7 @@ WHERE EXISTS {
RETURN n.name AS name,
n.age AS age
----
// end::conditional_queries_exists[]

`Alice` and `Charlie` are both older than `40,` so they are returned by the `WHEN` branch, while `Bob` is returned by the `ELSE` branch.
Note that some `Person` nodes in the graph are not matched in either branch of the conditional subquery, and are therefore not returned.
Expand Down Expand Up @@ -340,6 +348,7 @@ UNION [DISTINCT|ALL]
----

.Combining conditional branches with `UNION` using `{}`
// tag::conditional_queries_union[]
[source, cypher]
----
{
Expand All @@ -354,6 +363,7 @@ UNION
ELSE RETURN 6 AS x
}
----
// end::conditional_queries_union[]

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
Expand Down