删除Neo4j中的几个节点

时间:2018-01-05 21:46:20

标签: neo4j cypher

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

像这样...... (伪代码)

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

1 个答案:

答案 0 :(得分:3)

您可以使用IN list operator

如果id是属性:

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

如果id表示内部节点ID:

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