如何使用 APOC 反转关系
How to invert relationships using APOC
我正在使用 call apoc.refactor.invert(rel)
来反转关系方向。当我在已经创建的具有关系类型而不是 rel
的图形上尝试此操作时,它会给出错误
Type mismatch: expected Relationship but was String/float
当我尝试在使用以下查询创建关系时反转关系时
CALL apoc.create.relationship(a, graphName.connectionName, {}, b) yield rel1
call apoc.refactor.invert(rel1)
它给出错误
Neo.ClientError.Statement.SyntaxError: Unknown procedure output:
rel1
(line 7, column 67 (offset: 232)) "call
apoc.refactor.invert(rel1)
如果有人知道正确使用它,请帮助我。
您不能将关系类型用作 apoc.refactor.invert(rel)
过程的参数。此过程改为接受关系。
你的第二次尝试如果掉落是因为 apoc.create.relationship
没有产生 rel1
输出(你可以看到它 运行 call apoc.help("apoc.create.relationship")
)。此过程改为生成 rel
输出。
因此将您的代码更改为:
call apoc.create.relationship(a, graphName.connectionName, {}, b) yield rel
call apoc.refactor.invert(rel) yield input, output
我正在使用 call apoc.refactor.invert(rel)
来反转关系方向。当我在已经创建的具有关系类型而不是 rel
的图形上尝试此操作时,它会给出错误
Type mismatch: expected Relationship but was String/float
当我尝试在使用以下查询创建关系时反转关系时
CALL apoc.create.relationship(a, graphName.connectionName, {}, b) yield rel1
call apoc.refactor.invert(rel1)
它给出错误
Neo.ClientError.Statement.SyntaxError: Unknown procedure output:
rel1
(line 7, column 67 (offset: 232)) "call apoc.refactor.invert(rel1)
如果有人知道正确使用它,请帮助我。
您不能将关系类型用作 apoc.refactor.invert(rel)
过程的参数。此过程改为接受关系。
你的第二次尝试如果掉落是因为 apoc.create.relationship
没有产生 rel1
输出(你可以看到它 运行 call apoc.help("apoc.create.relationship")
)。此过程改为生成 rel
输出。
因此将您的代码更改为:
call apoc.create.relationship(a, graphName.connectionName, {}, b) yield rel
call apoc.refactor.invert(rel) yield input, output