Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apoc.refactor.mergeNodes while using apoc.periodic.iterate seems not working #500

Open
SimG92 opened this issue Oct 1, 2023 · 4 comments

Comments

@SimG92
Copy link

SimG92 commented Oct 1, 2023

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

@nadja-muller
Copy link
Contributor

Thank you for reporting this. We will have a look and come back to you.

@SimG92
Copy link
Author

SimG92 commented Oct 6, 2023

Thank you for reporting this. We will have a look and come back to you.

Thanks!

@cybersam
Copy link

Minor typo: The title of this Issue should say mergeNodes instead of merge.

@SimG92 SimG92 changed the title apoc.refactor.merge while using apoc.periodic.iterate seems not working apoc.refactor.mergeNodes while using apoc.periodic.iterate seems not working Oct 24, 2023
@SimG92
Copy link
Author

SimG92 commented Oct 24, 2023

Minor typo: The title of this Issue should say mergeNodes instead of merge.

Correct! Sorry :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants