Database Reference
In-Depth Information
simply leave the relationship type within the square brackets, after the colon character, just
as you did in the original query:
Nodes can similarly be anonymous. To make a node anonymous, use empty parentheses to
specifythenode, () .Toillustratethis,let'swriteanotherCypherquery,whereyouwantto
return all HAS_SEEN relationships from the user node, without worrying about movie
nodes:
Usingemptyparentheses,youdescribethefactthatyouexpectanode,butyou'renotinter-
estedinanyofitsproperties,nordoyouwanttoreferenceitlater,soyouleaveitunnamed.
Note
Named nodes can be specified without parentheses in a Cypher match clause, such
as start user=node(1) match user-[:HAS_SEEN]->movie return
movie . In complex queries, you can remove the parentheses where possible, to declutter
the query and make it more readable. Anonymous nodes must have parentheses.
All the patterns you've matched so far were quite simple, consisting of two nodes connec-
ted via a single relationship. Let's see how you can use more complex pattern matching
with Cypher.
Complex Pattern Matching
Cyphersupportsquitecomplexpatternmatching.Let'slookatanotherexample:findingall
movies that User 1's friends have seen. You already solved this problem using the Neo4j
Traversal API in chapter 4 , so let's see how you can solve it using Cypher:
Search WWH ::




Custom Search