Cypher Cheat Sheet
How the cheat sheet works
Example structure
[.neo4j-ee] (1)
==== (2)
[source, cypher, role=noheader] (3)
----
MATCH (n)
RETURN n AS node
----
[.description] (4)
-- (5)
Description
More description
--
[.extra] (6)
--
Additional content, to be used sparingly because this is a cheat sheet or quick reference, not a full Cypher reference manual.
--
====
1 | Add a role for each cheat-sheet that the example applies to. Leave blank if it applies in all cases. |
2 | Use an example block to contain the Cypher example and description. |
3 | Add an optional block for a Cypher example, specifying [source, cypher,`role=noheader ]. |
4 | Add a required description block. |
5 | If the description consists of more than one paragraph of text, use an open block. |
6 | If you need to, you can add extra content, which is displayed below the example code and description. |
Playbook configuration
asciidoc:
attributes:
page-cheatsheet-product: Neo4j (1)
page-cheatsheet-products: (2)
- name: 'Neo4j Enterprise Edition' (3)
label: 'Enterprise Edition' (4)
class: 'neo4j-ee' (5)
default: true (6)
- name: 'Neo4j Community Edition'
class: 'neo4j-ce'
- name: 'Deprecated'
class: 'deprecated'
label-only: true (7)
1 | Add a product name to displayed before Version in the version selector. The default value is Product . |
2 | Add a page-cheatsheet-products section to the playbook to define the different views that a user can choose from. In this example we’ve added two views: Neo4j Enterprise Edition and Neo4j Community Edition. |
3 | Add a name for each view. This text is displayed in the dropdown that you use to select which Cheat Sheet you want to view. |
4 | [Optional] Add label text. When an example is not applicable in all views, a label is displayed to indicate which views it applies to. If no label value is specified, the value of name is used. |
5 | Specify a class for each view. This is used to add a role to the example block. For example, the class neo4j-ee is specified by [.neo4j-ee] . |
6 | Specify a default view. This is the view that is displayed when the page is loaded. |
7 | If you want to display a label for some entries without that label appearing in the dropdown, you can use the label-only attribute. In this example, entries that have the [.deprecated] role will have the Deprecated label displayed, but 'Deprecated' is not an option you can select from the dropdown. In this preview build, both Configuration and Deprecated have been added as label-only views. |
Read queries
Read queries subsection
<CYPHER EXAMPLE>
This example only applies to Neo4j Enterprise Edition and is marked with the [.neo4j-ee]
role.
<CYPHER EXAMPLE>
Text describing the example. This example has no role, and therefore no labels. It is displayed in all views.
<CYPHER EXAMPLE>
This example only applies to Neo4j Enterprise Edition and is marked with the [.neo4j-ee]
role.
Write queries
Write queries subsection
<CYPHER EXAMPLE>
Text describing the example. This example has no role, and therefore no labels. It is displayed in all views.
<CYPHER EXAMPLE>
This example only applies to Neo4j Enterprise Edition and is marked with the [.neo4j-ee]
role.
Title with link
This entry has no example code.
This entry has no example code.
It contains:
-
more than one paragraph
-
a list
Therefore it is formatted as an open block
MATCH (n)
RETURN n AS node
Displayed for Neo4j Enterprise Edition
Some additional content. Can be any arbitrary asciidoc blocks and elements.
Name | Description |
---|---|
Asciidoctor |
Awesome way to write documentation |
Neo4j |
Graphy |
MATCH (n)
RETURN n AS node
Displayed for Neo4j Enterprise Edition
MATCH (n:A&B)
RETURN n.name AS name
This example is displayed in all views.
MATCH (n:A&B)
RETURN n.name AS name
This example is displayed for AuraDB Virtual Dedicated Cloud ([.aura-dbe]
)
MATCH (n:A|B)
RETURN n.name AS name
This example is displayed for both AuraDB Free and AuraDB Virtual Dedicated Cloud.
Not on Aura
Not on Aura examples
This section applies to Neo4j Community Edition and Neo4j Enterprise Edition. It does not apply to any flavour of Aura.
So, we’ve added two roles: [.neo4j-ce.neo4j-ee]
.
When generating a Neo4j (ie not Aura) cheat sheet, we would only add those two versions to the playbook:
- name: 'Neo4j Community Edition'
class: 'neo4j-ce'
- name: 'Neo4j Enterprise Edition'
class: 'neo4j-ee'
default: true
In this example the labels would not be displayed.
If we add any other versions to the playbook, such as AuraDB Virtual Dedicated Cloud, the labels will be displayed when viewing the examples for Neo4j Community Edition or Neo4j Enterprise Edition, but the content will be hidden entirely when viewing the AuraDB Virtual Dedicated Cloud examples.
Neo4j Community Edition Only
Labeling example
The title of this section has a [.neo4j-ce]
role. All subsections and examples within this section will be treated as Neo4j Community Edition only.
Labels are not automatically added to each subsection or example, but they are all hidden when a cheat sheet view other than Neo4j Community Edition is selected.
<NEO4J COMMUNITY EDITION CYPHER EXAMPLE>
This example is not explicitly marked as Neo4j Community Edition, but it is in a section that is marked as Neo4j Community Edition. It is displayed or hidden accordingly.
Deprecated
Deprecated examples
This section contains deprecated examples. The section has a [.deprecated]
role, and the subsection and examples also have the role.
That’s a lot of labels.
(neo4j:Neo4j {name: "Neo4j"})
(neo4j)-[:INCLUDES]->(browser:Product {name: "Neo4j Browser"})
(browser)-[:HAS]->(:Feature {name: "Cypher"})
(browser)-[:HAS]->(:Feature {name: "Dev Tools"})
(browser)-[:HAS]->(:Feature {name: "Visualization"})
(neo4j)-[:CONNECTS_WITH]->(drivers:Drivers {name: "Drivers"})
(drivers)-[:SUPPORTS]->(:Language {name: "Java"})
Deprecated cypher example.
Functions
Temporal functions
date('2018-04-05')
Returns a date parsed from a string.
localtime('12:45:30.25')
Returns a time with no time zone.
time('12:45:30.25+01:00')
Returns a time in a specified time zone.
localdatetime('2018-04-05T12:34:00')
Returns a datetime with no time zone.
datetime('2018-04-05T12:34:00[Europe/Berlin]')
Returns a datetime in the specified time zone.
datetime({epochMillis: 3360000})
Transforms 3360000 as a UNIX Epoch time into a normal datetime.
date({year: $year, month: $month, day: $day})
All of the temporal functions can also be called with a map of named components. This example returns a date from year, month and day components. Each function supports a different set of possible components.
datetime({date: $date, time: $time})
Temporal types can be created by combining other types. This example creates a datetime from a date and a time.
date({date: $datetime, day: 5})
Temporal types can be created by selecting from more complex types, as well as overriding individual components. This example creates a date by selecting from a datetime, as well as overriding the day component.
WITH date('2018-04-05') AS d
RETURN d.year, d.month, d.day, d.week, d.dayOfWeek
Accessors allow extracting components of temporal types.