apoc
apoc copied to clipboard
apoc.refactor.mergeNodes while using apoc.periodic.iterate seems not working
Hello, in my database I have multiple nodes that have the same properties, so I want to merge all of these nodes into one. Those nodes are connected by the relationship "similar", so I use gds weakly connected component to find these communities, then I'm using the following code to merge those nodes in the same community while using the apoc.periodic.iterate
CALL apoc.periodic.iterate(' MATCH (n:Officer) WITH n.community AS com, collect(n) AS nodicom RETURN nodicom ',' CALL apoc.refactor.mergeNodes(nodicom,{ properties:"discard", mergeRels:true, preserveExistingSelfRels:false}) YIELD node ',{batchSize: 200, parallel: true}) YIELD batches, total RETURN batches, total
I'm expecting that all nodes grouped by community will be merged but it does not working. Using the following code I have a lot of communities with more than 1 node:
match (n) with n.community as com, count(n) as contacom return com, contacom order by contacom desc
if I use:
MATCH (n:Officer) where n.community=239389 WITH n.community AS com, collect(n) AS nodicom CALL apoc.refactor.mergeNodes(nodicom,{ properties:"discard", mergeRels:true, preserveExistingSelfRels:false}) yield node return count(*)
it works. 239389 is an example of id community
Neo Desktop Version: 1.5.8 Database Version 5.5.0 APOC Version 5.5.0 on Windows 11 Home