Here's an example on the merge documentation page :
MERGE (keanu:Person { name:'Keanu Reeves' }) ON CREATE SET keanu.created = timestamp() ON MATCH SET keanu.lastSeen = timestamp() RETURN keanu.name, has(keanu.lastSeen);
This basically keeps your flag 0 or 1 in the existence or absence of the lastSeen attribute.
There is such an oddity in your request that you agree to “Charlie Sheen”, but then change the value that you agreed ( name ) to be “Charlie”. This is strange - it means that since you change it every time, even if you add an ON MATCH clause, it never works. You will create it every time and then change it, ensuring that it will be created new the next time you run this query. I would suggest that it is a bad idea to change the conditions of your match later in the request, unless this is a special circumstance.
source share