Copying different types of relationships using Cypher

I want to copy existing relationships to a new node. All nodes already exist, and I would like to copy all incoming relationships to the second node. Given node D and a graph like

 A -[r]-> B <-[s]- C 

I would like to create the following in one Cypher request:

 A -[r]-> B <-[s]- C A -[r]-> D <-[s]- C 

Only relationships in the second row should be created, since all other nodes already exist. I tried the following Cypher request (which is an invalid request ( Don't know how to extract parameters from this type: org.neo4j.kernel.impl.core.RelationshipProxy )):

 START targetNode = node(42) MATCH sourceNode -[r]-> targetNode CREATE sourceNode -[s:TYPE(r)]-> targetNode RETURN s 
0
source share
1 answer

Today there is no good way to do this. This is a very reasonable use case, so I would advise you to talk about it here: https://github.com/neo4j/community/issues

Thanks for sharing!

AndrΓ©s

0
source

Source: https://habr.com/ru/post/981112/


All Articles