简体   繁体   English

如何删除节点以及所有相关节点不仅关系— neo4j cypher 1.8

[英]how to delete node and all related nodes not only the relations — neo4j cypher 1.8

how to delete node and all related nodes not only the relations For Example 如何删除节点与所有相关节点之间不仅有关系例如

account-[:GGroup]-group,
group-[:GEvent]-event,
group-[:GMember]-member,
group-[:GAlbum]-album,
album-[:GPhoto]-photo,

So I want to delete group with all related nodes (event and album( and photo)), this is my work ... I'm using java. 所以我想删除所有相关节点(事件和相册(和照片))的组,这是我的工作...我正在使用Java。

    START group = node:GGroup('dbId:1') 
    MATCH group-[gp:privacy]-gPrivacy,
            group-[gm:GroupMember]-(),
            group-[ge:GroupEvent]-event,
            event-[ep:privacy]-gePrivacy,
            event-[eep:EventParticipant]-(),
            event-[ea:EventAlbum]-eventAlbum,
            eventAlbum-[ap:privacy]-geaPrivacy,
            eventAlbum-[aph:AlbumPhoto]-eventAlbumPhoto,
            eventAlbumPhoto-[ept:PhotoTag]-eventAlbumPhotoTag,
            event-[ev:EventVideo]-eventVideo,
            eventVideo-[vp:privacy]-gevPrivacy,
            group-[ga:GroupAlbum]-groupAlbum,
            groupAlbum-[gap:privacy]-gaPrivacy,
            groupAlbum-[aphoto:AlbumPhoto]-groupAlbumPhoto,
            groupAlbumPhoto-[gpt:PhotoTag]-groupAlbumPhotoTag,
            group-[gf:GroupFile]-groupFile 
            delete group,gm,ge,event,ep,gePrivacy,eep,ea,eventAlbum,ap,geaPrivacy
            ,aph,eventAlbumPhoto,ept,eventAlbumPhotoTag,ev,eventVideo,vp,gevPrivacy,ga,
            groupAlbum,gap,gaPrivacy,aphoto,groupAlbumPhoto,gpt,groupAlbumPhotoTag,gf,
            groupFile,gp
START g=node({id_of_group_node})
MATCH acc-[ag:GGroup]-g
     ,g-[ge:GEvent]-e
     ,g-[gm:GMember]-m
     ,g-[ga:GAlbum]-a
     ,a-[ap:GPhoto]-p
DELETE g, ge, e, gm, m, ga, a, ap, p, ag

in case you want to delete all related nodes, there is no need to explicitly match them one by one in the MATCH phase. 如果要删除所有相关节点,则无需在MATCH阶段一一对应地明确匹配它们。 you can simply find all except the starting one (+ the album photos): 您可以简单地找到除起始图片(+相册照片)以外的所有图片:

START account=node(...)
MATCH account-[:GGroup]-group,
      group-[r1]-all,
      group-[:GAlbum]-()-[r2]-photo
WHERE Id(all)<>Id(account)
DELETE group, r1, all, r2, photo.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过RestAPI删除Neo4j的所有节点和关系 - Delete all nodes and relations of Neo4j by RestAPI Neo4j:检索连接到Neo4j Rest中的节点或通过Cypher的所有节点和关系 - Neo4j : Retrieving All Nodes and Relationship connected to a Node in Neo4j Rest OR through Cypher Neo4j密码跟踪删除节点/关系 - Neo4j cypher keeping track of delete Nodes/relationships 删除与Neo4j密码查询的关系的结束节点 - Delete End Node to a relationship with neo4j cypher query 如何在Neo4j的Cypher中获取连接到集合中每个其他节点的节点? - How to get in Neo4j's Cypher the nodes that are connected to every other node within a set? Neo4j OGM查找节点及其相关节点 - Neo4j OGM find node with their related nodes 在Neo4j中删除节点及其所有关系 - Deleting a Node and all of its relations in Neo4j 如何在neo4j中搜索连接到特定顶级节点的所有节点和关系 - How to search for all nodes and relationships connected to a specific top node in neo4j Neo4j cypher计算并显示两个给定节点之间的所有关系 - Neo4j cypher to count and display all the relationship between two given nodes 使用Cypher Neo4j通过(从SQL世界中的表名中选择*)获取具有给定类型的所有节点 - Get all nodes with given type by ( select * from tablename in SQL world) with Cypher Neo4j
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM