获取每个标签/类型的计数
统计关系数
MATCH (n)-[r]->() RETURN COUNT(r)
删除节点
MATCH (r)
DETACH DELETE r
节点去重
MATCH (n:area)
WITH n.name AS name, COLLECT(n) AS nodelist, COUNT(*) AS count
WHERE count > 1
CALL apoc.refactor.mergeNodes(nodelist) YIELD node
RETURN node
关系去重
MATCH (a)-[r:影响所属器官或状态]->(b)
WITH a, b, TAIL (COLLECT (r)) as rr
WHERE size(rr)>0
FOREACH (r IN rr | DELETE r)
毒性兽药
MATCH (m:med)-[r1]-(n:影响)-[r3]-(q:器官或状态)
WHERE m.name = '氯霉素'
RETURN m,n,q
毒性农药
统计节点
MATCH (n)-[r]->() RETURN COUNT(r)
抽检查询
MATCH (p:med)-[r2:残留药物]-(m:food_event)-[r1:所属地区]-(n)
WHERE p.name = '多菌灵'
WITH p,m,n,r1,r2 match (t:res)-[r4:残留量]-(m:food_event)-[r3:抽检食物]-(q:food)
RETURN p,m,n,t,q
实体查询
MATCH (n:med{name:'多菌灵'}) RETURN n
增加属性
MATCH (n:med { name: '多菌灵' })SET n.medtype = '农药' RETURN n.name, n.medtype
残留+抽检
MATCH(t:AnimalType{name:'虾'})-[r5]-(q:res_event)-[r4]-(p:med)-[r2:残留药物]-(m:food_event)-[r1:抽检食物]-(n:food{foodtype:'水产'}) WHERE p.name = '金霉素' WITH r4,q,p, m, n,t, r1, r2,r5 match(q:res_event)-[r3]-(q1:MaxRes) RETURN q,p, m, n,t,q1