cancel
Showing results for 
Search instead for 
Did you mean: 

Skipping incoming relationships with apoc.clone

deepak
Node Clone

I am using the cloneNodes procedure for cloning a node with relationships:

apoc.refactor.cloneNodes(nodes :: LIST? OF NODE?, withRelationships = false :: BOOLEAN?, skipPropert...

This procedure accept properties that can be skipped while cloning. I am wondering if there is a way to skip relations. 

In my schema (x:Person)-[:FRIEND]->(y:Person)-[:FRIEND]->(z:Person), I am trying to clone the node "y" with only outgoing FRIEND relations. For now, I have taken the inefficient path of cloning all relations and then deleting the incoming ones. I have a limited number of outgoing relations but incoming ones are higher by multiples, so this approach has a significant performance hit. My last resort is to copy desired properties/relations with regular cypher (without apoc).

I am using Enterprise Edition 5.1.0 with APOC v5.1.0. APOC docs for 5.1 are not published yet, so the linked one may be outdated.

PS: Sorry about the formatting. None of the markdown tags are working - I have tried manually and through the visual editor.

4 REPLIES 4

glilienfield
Ninja
Ninja

The documentation states you can choose to skip relationships, by setting the second parameter to true.  It’s false by defaul.  How about you take the opposite approach and skip all relationships and add back the ones you want. 

There are a bunch of other outgoing relations that I need to copy as well. Perhaps thats why I was looking into the apoc library, cloning just the node properties is fairly straightforward and can be done without apoc.

Very true. When why not use cypher and roll your own?  

copying relations is not so straightforward and somewhat error prone, especially copying multiple types