neo4j数据库
作者:互联网
@
目录neo4j
https://neo4j.com/docs/cypher-refcard/current/ 参考卡片
neo4j存储格式
where子句
match(p:Person{name:"王涛"})-[r]-(n) return p;
MATCH xxx=()-[r:personCompany]->() RETURN xxx LIMIT 25
取出所有邻居
# 取出Tom的所有关联的边r和结点n。
match(p:person{name:"Tom"})-[r]-(n) return r,n;
# 取出所有ID=0的结点的personCompany邻居n1(返回包括结点n)
match (n:TaxPayer)-[:personCompany]-(n1) where n.tempID=0 return n,n1
# 取出所有ID=0的结点的 所有类型边 邻居n1(返回包括结点n)
match (n:TaxPayer)-[]-(n1) where n.tempID=0 return n,n1
二阶邻居
MATCH (js:Person)-[:KNOWS]-()-[:KNOWS]-(surfer)
WHERE js.name = "Johan" AND surfer.hobby = "surfing"
RETURN DISTINCT surfer
delete子句
# 删除所有结点
match ()-[r]-() match (n) delete r,n
规则积累
- match (ee:Person{name:"Emil"}) create(:Person{name:"heljg"})若match有匹配,则继续执行、插入结点;否则后面的语句将不执行。
MATCH (ee:Person) WHERE ee.name = "Emil"
CREATE (js:Person { name: "Johan", from: "Sweden", learn: "surfing" }),
(ir:Person { name: "Ian", from: "England", title: "author" }),
(rvb:Person { name: "Rik", from: "Belgium", pet: "Orval" }),
(ally:Person { name: "Allison", from: "California", hobby: "surfing" }),
(ee)-[:KNOWS {since: 2001}]->(js),(ee)-[:KNOWS {rating: 5}]->(ir),
(js)-[:KNOWS]->(ir),(js)-[:KNOWS]->(rvb),
(ir)-[:KNOWS]->(js),(ir)-[:KNOWS]->(ally),
(rvb)-[:KNOWS]->(ally)
若“Emil”结点存在,插入后面的结点和边。
标签:结点,name,数据库,js,Person,neo4j,match,KNOWS 来源: https://www.cnblogs.com/zzai/p/neo4j.html