I want to copy existing relationships to a new node. All nodes exist already and I would like to copy all incoming relationships to a second node. Given a node D
and a graph like
A -[r]-> B <-[s]- C
I would like to create the following in a single Cypher query:
A -[r]-> B <-[s]- C
A -[r]-> D <-[s]- C
Only the relationships in the second line should be created, as all other nodes exist already. I have tried the following Cypher query (which is an Invalid query (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
There doesn't exist any good way to do this today. It's a very reasonable use case though, so I would encourage you to raise an issue about it here: https://github.com/neo4j/community/issues
Thanks for sharing!
Andrés
来源:https://stackoverflow.com/questions/12387261/copy-relationships-of-different-type-using-cypher