Reputation: 24721
I am running neo4j-community-3.0.0-M05.
I am trying out Neo4J Cypher Query Language's MERGE clause. Its explanation is given as follows
It acts like a combination of
MATCH
orCREATE
, which checks for the existence of data first before creating it. WithMERGE
you define a pattern to be found or created. Usually, as withMATCH
you only want to include the key property to look for in your core pattern.MERGE
allows you to provide additional properties you want to setON CREATE
.
I already have following node:
(:Movie{title:"Forrest Gump", released:1994})
and now I wanted to add a dummy property addedOn
with dummy value 20160108
to it just to try out MERGE
clause:
MERGE (a:Movie{title:"Forrest Gump"})
ON CREATE SET a.addedOn= "20160108"
RETURN a;
However this seems not working:
Why is this so?
Upvotes: 0
Views: 399
Reputation: 39905
What you're seeing is precisely the expected behaviour.
Since MERGE
finds your pre-existing Forrest Gump, this node is used. The ON CREATE
handler will not fire since you didn't create anything.
If you've had a ON MATCH
handler this one would have been fired since MERGE
's match was successful.
Upvotes: 2