【neo4j】去除重复节点
生活随笔
收集整理的這篇文章主要介紹了
【neo4j】去除重复节点
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
問題
我們在使用neo4j批量導入數據的時候,有可能同一個命令導入多次,那么就會存在重復數據,這個時候怎么去除重復數據呢?
MATCH (n:Location {city:'Boston'}) RETURN n LIMIT 25;解決
1.找到重復的數據
match (n:Location) return count(n); # 13 match (n:Location) return count(distinct n.city); # 5 說明有6個是重復的 # 查看重復的id match (n:Location), (m:Location) where n.city = m.city and id(n) <> id(m) return n,id(n), m, id(m);2.刪除該id所在的關系
注意:這里有個邏輯,想要刪除某個節點,需要先刪除這個節點所在的關系
match (n:Person)-[r:BORN_IN]->(m:Location) where id(m)=6 delete r;3.刪除該id
match (n:Location) where id(n)=6 delete n; match (n:Location) where id(n) in [62,63,82] delete n;檢查
然后再檢查一遍:
match (n:Location) return count(n); # 5 match (n:Location) return count(distinct n.city); # 5 說明沒有重復的了參考:neo4j 刪除重復節點
總結
以上是生活随笔為你收集整理的【neo4j】去除重复节点的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: HTML基础练习2
- 下一篇: 【学习】自学JavaScript