我大约有470万个“实体节点”。其中许多是重复实体。我想合并相同的实体,并保持这些新组合的实体与它们所连接的事物之间的关系。我编写了以下查询来尝试执行此操作,但是它似乎没有用。对此,我们将给予任何帮助。
CALL apoc.periodic.iterate(
'MATCH (e:Entity)
WITH e.name AS name, e.entity_type AS type, collect(e) as nodes
CALL apoc.refactor.mergeNodes(nodes, {
properties: {
author_id:"combine",
author_name:"combine",
entity_hash:"combine",
entity_type:"combine",
forum_id:"combine",
name:"discard",
post_id:"combine",
thread_id:"combine"
}
}) YIELD node
RETURN count(node) AS new_node_count',
'',
{batchSize:100000}
)
风车不断旋转,但结点或其他任何事物却没有减少,这告诉我它已挂起。
答案 0 :(得分:0)
您没有正确使用过程apoc.periodic.iterate
。此过程需要2个查询:
因此,在您的提示中,查询应为:
CALL apoc.periodic.iterate(
'MATCH (e:Entity)
WITH e.name AS name, e.entity_type AS type, collect(e) as nodes
RETURN nodes',
'CALL apoc.refactor.mergeNodes(nodes, {
properties: {
author_id:"combine",
author_name:"combine",
entity_hash:"combine",
entity_type:"combine",
forum_id:"combine",
name:"discard",
post_id:"combine",
thread_id:"combine"
}
})',
{batchSize:500}
)
此外,我已将批次的大小减小到500,因为如果您有很多相同的节点,500
很酷(或1000
却很100000
很酷,否则您将拥有一些OOM)。
要查看此查询的性能,您可以预先测试第一个查询是否快速。