Why does my merge make a new node rather than match the existing one?

Viewed 21

When I run the following query:

MERGE (n:PERSON {name: "John Green", occupation: 'writer', age: 42})
on create set n.created = timestamp() 
on match set n.updated = timestamp() 
RETURN n

I get a node with all the appropriate metadata.

but once I run the second query

MERGE (p1:Person { name: 'John Green'}) 
on create set p1.created = timestamp() 
on match set p1.updated = timestamp() 

MERGE (p2:Person { name: 'Hank Green', occupation: 'youtuber'}) 
on create set p2.created = timestamp() 
on match set p2.updated = timestamp() 

MERGE (p1)-[r:Brother {since: '1942'}]->(p2) ON CREATE SET r.updated = timestamp() RETURN p1, p2, r

A second John Green node appears. How do I format my query so that Cypher recognizes that the John Green in the second query should be a Match and not a Create?

enter image description here

1 Answers

Ahh in query 1 I had PERSON (caps) and in the second I had Person (title case). It works now!

Related