Databases Reference
In-Depth Information
What we've done with the START clause is look up a real node in the graph—the node
representing Michael. We bind this Michael node to the a identifier; a then carries over
to the MATCH clause. This has the effect of anchoring our pattern to a specific point in
the graph. Cypher then matches the remainder of the pattern to the graph immediately
surrounding the anchor point. As it does so, it discovers nodes to bind to the other
identifiers. While a will always be anchored to Michael, b and c will be bound to a
sequence of nodes as the query executes.
RETURN
This clause specifies which nodes, relationships, and properties in the matched data
should be returned to the client. In our example query, we're interested in returning the
nodes bound to the b and c identifiers. Each matching node is lazily bound to its iden‐
tifier as the client iterates the results.
Other Cypher Clauses
The other clauses we can use in a Cypher query include:
WHERE
Provides criteria for filtering pattern matching results.
CREATE and CREATE UNIQUE
Create nodes and relationships.
DELETE
Removes nodes, relationships, and properties.
SET
Sets property values.
FOREACH
Performs an updating action for each element in a list.
UNION
Merges results from two or more queries (introduced in Neo4j 2.0).
WITH
Chains subsequent query parts and forward results from one to the next. Similar
to piping commands in Unix.
If these clauses look familiar—especially if you're a SQL developer—that's great! Cypher
is intended to be familiar enough to help you move rapidly along the learning curve. At
the same time, it's different enough to emphasize that we're dealing with graphs, not
relational sets.
Search WWH ::




Custom Search