MATCH
MATCH (n:Person)-[:KNOWS]->(m:Person)
WHERE n.name = 'Alice'

Node patterns can contain labels and properties.

MATCH (n)-[]->(m)

Any pattern can be used in MATCH.

MATCH (n {name: 'Alice'})-[]->(m)

Patterns with node properties.

WHERE
WHERE n.property != $value

Use a predicate to filter. Note that WHERE is always part of a MATCH, or WITH clause. Putting it after a different clause in a query will alter what it does.

RETURN
RETURN *

Return the value of all variables.

RETURN n AS columnName

Use alias for result column name.

RETURN DISTINCT n

Return unique rows.

ORDER BY n.property

Sort the result.

ORDER BY n.property DESC

Sort the result in descending order.

SKIP $skipNumber

Skip a number of results.

LIMIT $limitNumber

Limit the number of results.

SKIP $skipNumber LIMIT $limitNumber

Skip results at the top and limit the number of results.

RETURN count(*)

The number of matching rows. See Aggregating Functions for more.

WITH
MATCH (user)-[:FRIEND]-(friend)
WHERE user.name = $name
WITH user, count(friend) AS friends
WHERE friends > 10
RETURN user

The WITH syntax is similar to RETURN. It separates query parts explicitly, allowing you to declare which variables to carry over to the next part.

MATCH (user)-[:FRIEND]-(friend)
WITH user, count(friend) AS friends
ORDER BY friends DESC
  SKIP 1
  LIMIT 3
RETURN user

ORDER BY, SKIP, and LIMIT can also be used with WITH.

Patterns
(n:Person)

Node with Person label.

(n:Person {name: $value})

Node with the declared properties.

()-[r {name: $value}]-()

Matches relationships with the declared properties.

(n:Person)-[]->(m)

Node n labeled Person with relationship to m.

(m)<-[:KNOWS]-(n)

Relationship of type KNOWS from n to m.

(n)-[:KNOWS|:LOVES]->(m)

Relationship of type KNOWS or of type LOVES from n to m.

(n)-[*1..5]->(m)

Variable length path of between 1 and 5 relationships from n to m.

(n)-[*]->(m)

Variable length path of any number of relationships from n to m.

(n)-[:KNOWS]->(m {property: $value})

A relationship of type KNOWS from a node n to a node m with the declared property.

Labels
MATCH (n:Person)

Matches nodes labeled Person.

MATCH (n:Person)
WHERE n.name = $value

Matches nodes labeled Person with the given name.

labels(n)

Labels of the node.

Operators

General

DISTINCT, ., []

Mathematical

+, -, *, /,

Comparison

=, !=, <, >, <=, >=

Boolean

AND, OR

String

+

String Functions
toString($expression)

String representation of the expression.

left($original, $subLength),
  right($original, $subLength)

The first part of a string. The last part of the string.

trim($original), lTrim($original),
  rTrim($original)

Trim all whitespace, or on the left or right side.

toUpper($original), toLower($original)

UPPERCASE and lowercase.

reverse($original)

Reverse a string.

Aggregating Functions
count(*)

The number of matching rows.

count(variable)

The number of non-null values.

sum(n.property)

Sum numerical values. Similar functions are avg(), min(), max().

percentileDisc(n.property, $percentile)

Discrete percentile. Continuous percentile is percentileCont(). The percentile argument is from 0.0 to 1.0.

stDev(n.property)

Standard deviation for a sample of a population. For an entire population use stDevP().