Krishna Shetty
Krishna Shetty

Reputation: 1441

MERGE when one of the property has unique constraint

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

Upvotes: 4

Views: 2068

Answers (1)

Nicole White
Nicole White

Reputation: 7800

Use SET:

MERGE (b:Book {id:{id1}})
SET b.name = {name1}
RETURN b

Upvotes: 9

Related Questions