我正在尝试删除20000个具有datestamp属性= 20130808的节点但是当我用“RETURN COUNT(nx)”替换“DELETE nx”时结果是7880而不是20000,此时我在Neo4j 1.9中有1000000个节点0.2。我怎样才能正确地做到这一点?
Cypher查询:
START nx=node(*)
WITH nx
LIMIT 20000
WHERE HAS (nx.datestamp) AND nx.datestamp = 20130808 AND ID(nx) <> 0
DELETE nx
答案 0 :(得分:5)
这是因为您首先选择20k任意节点,然后应用WHERE
过滤器。你必须反过来这样做:
START nx=node(*)
WHERE HAS (nx.datestamp) AND nx.datestamp = 20130808 AND ID(nx) <> 0
WITH nx
LIMIT 20000
DELETE nx
请注意,这种具有属性访问权限的全局操作非常昂贵。更好的方法是为datestamp启用自动索引,然后执行:
START n=node:node_auto_index(datestamp=20130808)
WITH n
LIMIT 20000
DELETE n