使用 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 查询(这是一个无效查询(不知道如何从此类型中提取参数: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
感谢分享!
安德烈斯
这篇关于使用 Cypher 复制不同类型的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!