简体   繁体   English

Neo4j cypher 查询删除a特定节点的子节点和孙节点

[英]Neo4j cypher query to delete child and grandchild nodes of a a specific node

I'm looking for a cypher query to include in python module where I'm trying to delete a the nodes and sub nodes along with relationships of them if one specific node property matches.我正在寻找一个 cypher 查询以包含在 python 模块中,如果一个特定的节点属性匹配,我试图删除节点和子节点以及它们之间的关系。 For example, if Node match I found is match (n) where n.name = 'parent' Then I want to delete all the nodes/relationships connected to that specific node along with sub-nodes and their relationships of those nodes I am trying to delete.例如,如果我发现的节点匹配是 match (n) where n.name = 'parent' 然后我想删除连接到该特定节点的所有节点/关系以及我正在尝试的那些节点的子节点及其关系删除。

Sample Data: https://photos.app.goo.gl/5PPnNSLVRKvJzm6a8示例数据: https://photos.app.goo.gl/5PPnNSLVRKvJzm6a8

So, basically I am looking for the query which will delete all the nodes(N1 to N8) after parents node (PN1) and associated relationships.所以,基本上我正在寻找将删除父节点 (PN1) 和关联关系之后的所有节点(N1 到 N8)的查询。 So PN1 and rest of other nodes having incoming relationships will stay.所以其他有传入关系的节点的PN1和rest会留下来。

Have you tried something like that:你有没有试过这样的事情:

MATCH (n)--(p)--(gp) WHERE n.name = 'parent' DETACH DELETE p, gp匹配 (n)--(p)--(gp) WHERE n.name = 'parent' DETACH DELETE p, gp

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM