neo4j 删除从一个node开始的所有数据。

##一、 需求

删除红线右边重复的数据


二、 删除与中心点1的右边连线

2.1 中心点1橙色:
bash 复制代码
<elementId>: 4:fbde4fa1-3453-4e00-91ce-92b16aec22e3:425
<id>: 425
fileName: /Users/guibing.gao/Desktop/lib

2.2 与中新点1右边链接的node

bash 复制代码
<elementId>: 4:fbde4fa1-3453-4e00-91ce-92b16aec22e3:427
<id>: 427
fileName: /adaptor-1.0-SNAPSHOT.jar
valid: true
2.3 查询与中心点1链接的线
bash 复制代码
MATCH p =(a:Directory:File)-[r]-(b)
WHERE a.fileName = '/Users/guibing.gao/Desktop/lib' and b.fileName = '/adaptor-1.0-SNAPSHOT.jar'
return  a ,r,b
2.4 删除右边与中心点1的连线。
bash 复制代码
MATCH p =(a:Directory:File)-[r]-(b)
WHERE a.fileName = '/Users/guibing.gao/Desktop/lib' and b.fileName = '/adaptor-1.0-SNAPSHOT.jar'
delete r
2.5 查看数据 只剩一个中心点2

三、删除与中心点2的右边连线

3.1 中心点2绿色:
bash 复制代码
<elementId>: 4:fbde4fa1-3453-4e00-91ce-92b16aec22e3:480
<id>: 480
fqn: org.example:adaptor:jar:1.0-SNAPSHOT
group: org.example
name: adaptor
type: jar
version: 1.0-SNAPSHOT
3.2 与中心点2 链接的右边node
bash 复制代码
<elementId>: 4:fbde4fa1-3453-4e00-91ce-92b16aec22e3:467
<id>: 467
artifactId: adaptor
characterEncodingScheme: UTF-8
fileName: /META-INF/maven/org.example/adaptor/pom.xml
groupId: org.example
lineNumber: 1
packaging: jar
standalone: false
valid: true
version: 1.0-SNAPSHOT
xmlVersion: 1.0
xmlWellFormed: true
3.3 删除右边与中心点2的连线。
bash 复制代码
MATCH p =(a:Artifact:Maven)-[r]-(b)
WHERE a.fqn = 'org.example:adaptor:jar:1.0-SNAPSHOT' and id(b) = 467
delete r
3.4 查看数据

三 、删除右边图形的全部数据

3.1 确认起始node
bash 复制代码
MATCH (f:Document:File:Maven:Pom:Xml)
where id(f) = 467
return f
3.2 删除从这个点开始的所有数据
bash 复制代码
MATCH (f:Document:File:Maven:Pom:Xml)
where id(f) = 467
CALL apoc.path.subgraphNodes(f, {})
YIELD node
detach delete  node;
3.3 查看数据

完成需求

相关推荐
隆里卡那唔7 小时前
在dify中通过http请求neo4j时为什么需要将localhost变为host.docker.internal
http·docker·neo4j
疯子的模样7 小时前
Docker 安装 Neo4j 保姆级教程
docker·容器·neo4j
晋丑丑12 天前
从 0 到 1 构建 Graph RAG 系统:本地图谱 + 通义千问落地实践
前端·后端·python·neo4j
Lightning_201712 天前
Neo4j.5.X社区版创建数据库和切换数据库
数据库·oracle·neo4j
南城尽相思13 天前
Neo4j常见语句-merge
neo4j
南城尽相思14 天前
Neo4j常用语法-path
neo4j
just-do-it-zzj14 天前
[neo4j]介绍4个开源的知识图谱项目
人工智能·知识图谱·neo4j
2501_9153738815 天前
Neo4j操作指南:修改节点数据与新增节点属性
neo4j
BC-AGIOne16 天前
Tensorflow推理时遇见PTX错误,安装CUDA及CuDNN, 解决问题!
neo4j
南城尽相思16 天前
Neo4j常见语法-unwind
neo4j