MATCH (root{type:'admin' }),(guest{type:'guest'}) CREATE (root)-[r:knows]->(guest) RETURN r
Create Unique RelationShip
1 2 3
MATCH (root{type:'admin' }) CREATEUNIQUE (root)-[r:knows]-(u5:User{name:'user5'}) RETURN u5
match Node
match by property
1 2
MATCH (root { name : 'root' }) return root
match by ID identifier
1 2 3
MATCH (s) WHERE ID(s) = 65110 RETURN s
complex query
1 2 3 4 5 6 7 8
MATCH (d:District {state: {state}, district: {district}}) MATCH (d)<-[:REPRESENTS]-(l:Legislator) MATCH (l)-[:SERVES_ON]->(c:Committee) MATCH (c)<-[:REFERRED_TO]-(b:Bill) MATCH (b)-[:DEALS_WITH]->(s:Subject) WITH l.govtrackID AS govtrackID, l.lastName AS lastName, l.firstName AS firstName, l.currentParty AS party, s.title AS subject, count(*) AS strength, collect(DISTINCT c.name) AS committees ORDERBY strength DESCLIMIT10 WITH {lastName: lastName, firstName: firstName, govtrackID: govtrackID, party: party, committees: committees} AS legislator, collect({subject: subject, strength: strength}) AS subjects RETURN {legislator: legislator, subjects: subjects} AS r
match relationNode
1 2
MATCH (root{ type:'admin' })-->(user) RETURN user
match Node and relationNode
1 2
MATCH (root { type:'admin' })-[r]-(user) RETURN r
match collection
collection contain string
1 2 3
match (an) where all (x IN ['709908DCF9D24734BA8FEF8A831F1BA4'] where x in an.preAddressNodeGUIDs) return count(an)
collection equal
1 2
match (an{preAddressNodeGUIDs:['709908DCF9D24734BA8FEF8A831F1BA4 ']}) return count(an)
delete relationship
delete a node with its relationships
1
MATCH (n { name:'Andres' })DETACH DELETE n
delete all relationships
1 2
Match (:AddressNode)-[r:parent]->(:AddressNode) delete r
start
The START clause should only be used when accessing legacy indexes Legacy Indexing. In all other cases, use MATCH instead (see Section 11.1, “Match”). In Cypher, every query describes a pattern, and in that pattern one can have multiple starting points. A starting point is a relationship or a node where a pattern is anchored. Using START you can only introduce starting points by legacy index seeks. Note that trying to use a legacy index that doesn’t exist will generate an error.