删除Neo4j中的几个节点 [英] Delete several nodes in Neo4j

查看:519
本文介绍了删除Neo4j中的几个节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个要删除的节点ID的数组.我可以找到的每个Cypher示例都删除一个节点或删除所有节点.一个查询中如何删除与ID数组匹配的节点?

I have an array of multiple IDs of nodes to delete. Every Cypher example I can find either deletes one node or all nodes. How would one delete nodes that match an array of IDs, in a single query?

类似这样的东西... (伪代码):

Something like this... (pseudocode):

MATCH (n:Node) WHERE (n.id in ['id_a', 'id_b']) DELETE n;

推荐答案

您可以使用 IN列表运算符:

You can use the IN list operator:

如果id是属性:

WITH [1,2,3,4] AS ids
MATCH (n) WHERE n.id IN ids
DETACH DELETE n;

如果用id表示内部节点ID:

If by id you mean the internal node id:

WITH [1,2,3,4] AS ids
MATCH (n) WHERE id(n) IN ids
DETACH DELETE n;

这篇关于删除Neo4j中的几个节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆