How do I create and update nodes and property using plain cypher query?
Below is my query:
MERGE (c:contact {guid : '500010'})
ON CREATE SET
    c.data_source = '1',
    c.guid = '500010',
    c.created = timestamp()
ON MATCH SET
    c.lastUpdated = timestamp()
MERGE (s:speciality {specialtygroup_desc : 'cold'})
ON CREATE SET s.data_source = '1',
    s.specialtygroup_desc = 'fever',
    s.created = timestamp()
ON MATCH SET s.data_source = '1',
    s.specialtygroup_desc = 'comman cold',
    s.lastUpdated = timestamp()
MERGE (c)-[r:is_specialised_in]->(s)
ON CREATE SET
    r.duration = 1
ON MATCH SET
    r.duration = r.duration + 1
On the first run, node is created as "fever". On the second run, I have updated the specialty_group to "common cold". But it is creating new node with "fever". I am not able to update the "fever" to "common cold". What changes should I make to the above query?
 
                        
The
MERGE (s:speciality {specialtygroup_desc : 'cold'})clause looks for aspecialtygroup_descvalue of "cold".During the first execution, that
MERGEclause finds no "cold" node -- so it creates one, and the subsequentON CREATEclause changes it to "fever".During the second execution, that
MERGEagain finds no "cold" node (since it is now a "fever" node), so it again creates a "cold" node and theON CREATEclause yet again changes it to "fever". TheON MATCHclause is never used. This is why you end up with another "fever" node.Unfortunately, you have not explained your use case in enough detail to offer a recommendation for how to fix your code.