I'm trying to write a Cypher query to create multiple nodes and relationships in one query. The documentation on using CREATE clauses in Cypher states that it's not possible to create multiple nodes of different types in a singular CREATE clause.
However it hints that I should be able to break it up into multiple CREATE's. A couple of similar answers I have read point to the same solution as well. I've tried doing this and keep getting the response error.
Error: If you create multiple elements, you can only create one of each.
Here is a brief outline of what I'm trying to do.
- Create an
itemnode. - Create multiple
representationnodes. - Create a relationship between the created
itemnode and an existingstacknode. - Create multiple relationships between the created
itemnode and the createdrepresentationnodes.
This is the query I'm currently using which attempts to break up all the individual parts of the CREATE process into individual steps.
START stack=node({stack})
CREATE (item {item})
CREATE (representations {representations})
CREATE (stack)-[:Item]->(item)
CREATE (item)-[:Representation]->(representations)
RETURN item, representations
I've tried several variations of the above query, including putting the creation of the item and representation nodes at the beginning of the query.
I would really appreciate any advice. I really don't want to resort to making multiple database calls if it can be avoided.