Neo4j Rest Transactional HTTP Endpoint Cypher:在一个请求中创建多个唯一关系
Neo4j Rest Transactional HTTP Endpoint Cypher: Create multiple unique Relations within one request
如何在一个请求中创建多个关系?
以下示例请求导致以下错误:Neo.ClientError.Statement.InvalidSyntax","message":"WITH is required between CREATE UNIQUE and MATCH(第 1 行,第 281 列)
端点:
事务性 Cypher HTTP 端点
http://localhost:7474/db/data/transaction/commit
要求:
{"statements":[{"statement":"
MATCH (nA0:Test{name:'Test B'}), (nB0:Test{name:'Test A'})
CREATE UNIQUE (nA0)-[r:has_parent]->(nB0)
MATCH(nA1:Test{name:'Test C'}), (nB1:Test{name:'Test A'})
CREATE UNIQUE (nA1)-[r:has_parent]->(nB1)"}]}
如果我只提交一个 MATCH ... CREATE UNIQUE 语句,是否需要特定的分隔符?
非常感谢!
编辑:
将语句分组为单个 MATCH 和 CREATE UNIQUE 可行,但语句的分离更适合我的目的。
{"statements":[{"statement":" MATCH(nSrc0:Test{name:'Test B'}),(nTrgt0:Test{name:'Test A'}),(nSrc1:Test{name:'Test C'}),(nTrgt1:Test{name:'Test A'}) CREATE UNIQUE (nSrc0)-[r0:has_parent]->(nTrgt0), (nSrc1)-[r1:has_parent]->(nTrgt1)"}]}
如错误所述,您必须在 CREATE UNIQUE 和下一个 MATCH 之间添加一个 WITH 以将写入子句与读取子句分开。
- 将这两个语句放在请求中的两个单独条目中
- 使用参数
- 使用 MERGE 而不是 CREATE UNIQUE
见:
{"statements":[
{"statement":
"MATCH (a:Test{name:{name_a}}), (b:Test{name:{name_b}}) MERGE (a)-[:has_parent]->(b)",
"parameters":{"name_a":"Test B","name_b":"Test A"}},
{"statement":
"MATCH (a:Test{name:{name_a}}), (b:Test{name:{name_b}}) MERGE (a)-[:has_parent]->(b)",
"parameters":{"name_a":"Test C","name_b":"Test A"}},
...
]}
如何在一个请求中创建多个关系? 以下示例请求导致以下错误:Neo.ClientError.Statement.InvalidSyntax","message":"WITH is required between CREATE UNIQUE and MATCH(第 1 行,第 281 列) 端点: 事务性 Cypher HTTP 端点 http://localhost:7474/db/data/transaction/commit
要求:
{"statements":[{"statement":"
MATCH (nA0:Test{name:'Test B'}), (nB0:Test{name:'Test A'})
CREATE UNIQUE (nA0)-[r:has_parent]->(nB0)
MATCH(nA1:Test{name:'Test C'}), (nB1:Test{name:'Test A'})
CREATE UNIQUE (nA1)-[r:has_parent]->(nB1)"}]}
如果我只提交一个 MATCH ... CREATE UNIQUE 语句,是否需要特定的分隔符?
非常感谢!
编辑: 将语句分组为单个 MATCH 和 CREATE UNIQUE 可行,但语句的分离更适合我的目的。
{"statements":[{"statement":" MATCH(nSrc0:Test{name:'Test B'}),(nTrgt0:Test{name:'Test A'}),(nSrc1:Test{name:'Test C'}),(nTrgt1:Test{name:'Test A'}) CREATE UNIQUE (nSrc0)-[r0:has_parent]->(nTrgt0), (nSrc1)-[r1:has_parent]->(nTrgt1)"}]}
如错误所述,您必须在 CREATE UNIQUE 和下一个 MATCH 之间添加一个 WITH 以将写入子句与读取子句分开。
- 将这两个语句放在请求中的两个单独条目中
- 使用参数
- 使用 MERGE 而不是 CREATE UNIQUE
见:
{"statements":[
{"statement":
"MATCH (a:Test{name:{name_a}}), (b:Test{name:{name_b}}) MERGE (a)-[:has_parent]->(b)",
"parameters":{"name_a":"Test B","name_b":"Test A"}},
{"statement":
"MATCH (a:Test{name:{name_a}}), (b:Test{name:{name_b}}) MERGE (a)-[:has_parent]->(b)",
"parameters":{"name_a":"Test C","name_b":"Test A"}},
...
]}