使用Cypher复制不同类型的关系 [英] Copy relationships of different type using Cypher
问题描述
我想将现有关系复制到新节点.所有节点已经存在,我想将所有传入关系复制到第二个节点.给定一个节点D
和一个图
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
我想在一个Cypher查询中创建以下内容:
I would like to create the following in a single Cypher query:
A -[r]-> B <-[s]- C
A -[r]-> D <-[s]- C
仅应创建第二行中的关系,因为所有其他节点已经存在.我已经尝试了以下Cypher查询(这是一个无效查询(Don't know how to extract parameters from this type: org.neo4j.kernel.impl.core.RelationshipProxy
)):
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
推荐答案
今天没有任何好的方法可以做到这一点.不过,这是一个非常合理的用例,因此我鼓励您在这里提出一个问题: https://github.com/neo4j/community/issues
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
感谢分享!
安德烈斯(Andrés)
Andrés
这篇关于使用Cypher复制不同类型的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!