in brief: how can we MERGE
multiple nodes and relations just like the way we do with MATCH
and CREATE
: we can do multiple CREATE
or MATCH
for nodes or relations, separated with comma, but this action is not allowed with MERGE
in detail: suppose I have two graphs:
G1: (a)-[r1]->(b)<-[r2]-(c)
G2: (a)-[r1]->(b)<-[r3]-(d)
I have G1
inserted in neo4j, and G2
ready to push to db. The normal way to do it is to merge each node pair and then merge the relation; in this example for r1
relation there would be no change in db, since G1
already has the relation, however for the second one, my CQL first create node d
then add relation r3
Is there a way to push G2
to db in one step? something like:
MERGE (a), (b), (c), (a)-[r1]->(b)<-[r3]-(d)
to create such result:
(a)-[r1]->(b)<-[r2]-(c)
^
|
[r3]
|
(d)