Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MERGE when one of the property has unique constraint

Tags:

neo4j

cypher

I am trying to create or update a node using below query:

MERGE (u:Book{id:{id1},name:{name1}}) RETURN u

In this, id is unique but name can be changing.

But, this does not work for update.

I get below error:

Node 38 already exists with label Book and property "id"=[1166]

Can't I use MERGE when one of the property has unique constraint?

Note: Version: neo4j-enterprise-2.0.1 schema: Indexes ON :Book(id) ONLINE (for uniqueness constraint)

Constraints ON (book:Book) ASSERT book.guid IS UNIQUE

like image 719
Krishna Shetty Avatar asked Jan 11 '23 12:01

Krishna Shetty


1 Answers

Use SET:

MERGE (b:Book {id:{id1}})
SET b.name = {name1}
RETURN b
like image 56
Nicole White Avatar answered Jan 14 '23 23:01

Nicole White