Copy relationships of different type using Cypher

不想你离开。 提交于 2019-12-02 17:51:44

问题


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

回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!