Basic Cypher Queries
Good Resources
Create Database
ENTERPRISE ONLY FEATURE
-
Use docker to run multiple instances
-
Sources
- Docker example
- Database management - Neo4j Cypher Manual
List nodes's in database
// Just nodes
MATCH (n) RETURN n;
// Nodes that have a relationship to another node
Match (n)-[r]->(m)
Return n,r,m;
// Match A Specific node label
// Match A Specific relationship
// Match A Specific property on a node
// Match a Specific property on a relationship
// Nodes that have a specific label
// Relationships that have a specific property
View Schema
CALL db.schema.visualization()
Delete everything in database
MATCH (n)
DETACH DELETE n
- Sources
- DELETE - Neo4j Cypher Manual
Input some basic data
//data stored with this direction
// Node, Label, Relationship Property
// Create a node with a
CREATE (p:Person)-[:LIKES]->(t:Technology)
CREATE (ee:Person {name: 'Emil', from: 'Sweden', kloutScore: 99})
- Sources
- CREATE - Neo4j Cypher Manual
Matching
//query relationship backwards will not return results
MATCH (p:Person)<-[:LIKES]-(t:Technology)
//better to query with undirected relationship unless sure of direction
MATCH (p:Person)-[:LIKES]-(t:Technology)