Cypher Query: Fundamental - srijan-singh/neo4j-lineage GitHub Wiki
Retrieval
Retrieves Data
MATCH (p:Person {name: "Kevin Bacon"})
RETURN p.born
Retrieves Data via Relationships
MATCH (m:Movie)<-[:ACTED_IN]-(p:Person)
RETURN m.title, p.name
MATCH (m:Movie {title: "Cloud Atlas"} )<-[:DIRECTED]-(p:Person)
RETURN p.name
MATCH (p:Person)-[:ACTED_IN]->(m:Movie)
WHERE m.title = 'As Good as It Gets' AND p.born > 1960
RETURN p.name
Creation
Creating Node
MERGE (p:Person {name: 'Lucille Ball'})
-[:ACTED_IN]->
(m:Movie {title: 'Mame'})
RETURN p, m
Creating Relationship
MATCH (p:Person {name: 'Daniel Kaluuya'})
MERGE (m:Movie {title: 'Get Out'})
MERGE (p)-[:ACTED_IN]->(m)
Updation
Updating Nodes
MERGE (p:Person {name: 'Lucille Ball'})
ON MATCH
SET p.born = 1911
RETURN p
Adding attributes
MATCH (m:Movie {title: 'Get Out'})
SET m.tagline = 'Gripping, scary, witty and timely!',
m.released = 2017
Removing Attributes
MATCH (m:Movie)
REMOVE m.tagline
RETURN m
Deletion
Delete Nodes
MATCH (p:Person {name: 'River Phoenix'})
DETACH DELETE p