我正在尝试编写Cypher查询以在一个查询中创建多个节点和关系.有关在Cypher中使用CREATE子句的文档表明,不可能在单个CREATE子句中创建不同类型的多个节点.
然而,它暗示我应该能够将其分解为多个CREATE.我读过的几个类似的答案也指向了相同的解决方案.我试过这样做并继续得到响应错误.
Error: If you create multiple elements,you can only create one of each.
这是我正在尝试做的简要概述.
>创建项目节点.
>创建多个表示节点.
>在创建的项目节点和现有堆栈节点之间创建关系.
>在创建的项目节点和创建的表示节点之间创建多个关系.
这是我正在使用的查询,它试图将CREATE过程的所有单个部分分解为单个步骤.
START stack=node({stack}) CREATE (item {item}) CREATE (representations {representations}) CREATE (stack)-[:Item]->(item) CREATE (item)-[:Representation]->(representations) RETURN item,representations
你的陈述是一个清单吗?然后,您只能将其作为单个create语句.
我从你的语法中假设Neo4j 1.9.
你可以做的是使用FOREACH
START stack=node({stack}) CREATE (item {item}) CREATE (stack)-[:Item]->(item) FOREACH (r in {representations} : CREATE (representation {r}),(item)-[:Representation]->(representation) ) MATCH (item)-[:Representation]->(representations) RETURN item,representations