nosql - Cypher query to create multiple nodes and relationships -
i'm trying write cypher query create multiple nodes , relationships in 1 query. documentation on using create
clauses in cypher states it's not possible create multiple nodes of different types in singular create
clause.
however hints should able break multiple create
's. couple of similar answers have read point same solution well. i've tried doing , keep getting response error.
error: if create multiple elements, can create 1 of each.
here brief outline of i'm trying do.
- create
item
node. - create multiple
representation
nodes. - create relationship between created
item
node , existingstack
node. - create multiple relationships between created
item
node , createdrepresentation
nodes.
this query i'm using attempts break individual parts of create
process 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 above query, including putting creation of item
, representation
nodes @ beginning of query.
i appreciate advice. don't want resort making multiple database calls if can avoided.
is representations list ? can have single create statement.
i assume neo4j 1.9 syntax.
what can though use 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
Comments
Post a Comment