Skip to content

Instantly share code, notes, and snippets.

@zii
Last active February 24, 2018 01:16
Show Gist options
  • Save zii/dcc748d71842640cdd302ae710c66329 to your computer and use it in GitHub Desktop.
Save zii/dcc748d71842640cdd302ae710c66329 to your computer and use it in GitHub Desktop.
创建节点
create (a:Hum{name:"cat"})
更新节点属性
match (r:Role) where id(r)=1054808 set r.intro="呵呵", r.weight=2
创建关系
match (a:Hum),(b:Hum) where id(a)=435 and id(b)=436 create(a)-[r:KNOWS{time:1}]->(b) return r
merge会防止重复创建关系
match (a:Hum),(b:Hum) where id(a)=435 and id(b)=436 merge (a)-[r:KNOWS{time:1}]->(b) return r
通过ID删除关系
match (a:Hum)-[r]-(b:Hum) where id(a)=435 and id(b)=436 and r.time=1 delete r
删除一个节点
match ()-[r]-(role:Role) where role.name="诸葛亮" delete r
match (r:Role) where role.name="诸葛亮" delete r
创建索引
CREATE INDEX ON :Person(firstname)
移除索引
DROP INDEX ON :Album(Name)
创建唯一索引
CREATE CONSTRAINT ON (n:Person)
ASSERT n.name IS UNIQUE
关联查询
match (p:Person)-[:play]->(r:Role) where id(r)=1054808 return p, r limit 1
类似left join的查询
match (ro:Role) optional match (p:Person)-[r]->(ro) where ro.tvid=1047409 return p,ro
二度关系
match (a:Person)-[r*..2]-(b:Person) where id(a)=7 and id(b)=1472979 return r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment