Merge multiple nodes into single node with relations

578 views
Skip to first unread message

Pawan Wagh

unread,
Aug 23, 2017, 3:05:11 PM8/23/17
to Neo4j
Hii,
     My current project runs on neo4j and mongodb as database servers. We are having multiple nodes for single user with multiple bi-directional relations. Now the situation is user can request to claim his profile in which i need to merge all available nodes of user into one node with all existing relations to & from that newly generated node. Label for relations may or may not be known so is there any way of merging multiple nodes into one without knowledge of their relations.Please help or any suggestion on how to achieve this are most welcome.

neo4j version : 3.1.1
backend : nodejs
framework : loopback ( strongloop )

Michael Hunger

unread,
Aug 23, 2017, 8:09:29 PM8/23/17
to ne...@googlegroups.com
You can use the apoc procedures with apoc.refactor.mergeNode([nodes])


Michael

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pawan Wagh

unread,
Aug 24, 2017, 12:08:38 AM8/24/17
to Neo4j

Thanks for your suggestion. But what about redirecting all relationships of two nodes into that one node.

To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.

Michael Hunger

unread,
Aug 24, 2017, 3:54:18 AM8/24/17
to ne...@googlegroups.com
That will happen automatically.

To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscribe@googlegroups.com.

Pawan Wagh

unread,
Aug 28, 2017, 10:52:51 AM8/28/17
to ne...@googlegroups.com
Hi Michael, are you sure about this.I mean the node's which may be merging could have hundreds of relationships in & out.Sorry to bother but i am not able to figure this out.

--
You received this message because you are subscribed to a topic in the Google Groups "Neo4j" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/neo4j/ux0PjQge4tY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to neo4j+unsubscribe@googlegroups.com.

Michael Hunger

unread,
Aug 28, 2017, 3:00:22 PM8/28/17
to ne...@googlegroups.com
You can just try it in an example db

Yes, it could even have tens of thousands of relationships.


Reply all
Reply to author
Forward
0 new messages