我有一组要删除的多个节点ID。我可以找到每个Cypher示例删除一个节点或所有节点。如何在单个查询中删除与ID数组匹配的节点?
像这样...... (伪代码):
MATCH (n:Node) WHERE (n.id in ['id_a', 'id_b']) DELETE n;
答案 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;