0

I have created a neo4j DB locally and assigned some indices and unique constraint.

Here is the :schema

Indexes
  ON :Actor(social_id) ONLINE (for uniqueness constraint) 
  ON :Category(name)   ONLINE (for uniqueness constraint) 

Constraints
  ON (actor:Actor) ASSERT actor.social_id IS UNIQUE
  ON (category:Category) ASSERT category.name IS UNIQUE

Additionally I do a createIfNotFound() in my java code, where I first do a find and then create if not found.

Inspite of these two checks I still see multiple nodes of Label category and same name existing in the DB.

 MATCH (n:Category) WHERE n.name='garden' RETURN n

name    garden
name    garden
name    garden
name    garden
Returned 4 rows in 49 ms.

I am not sure what I am missing, and why is the unique constraint not being honored.

lazywiz
  • 1,091
  • 2
  • 13
  • 26
  • Can you drop and recreated the unique constraint? I assume you will get an error here. – Stefan Armbruster Oct 04 '15 at 08:13
  • 1
    Did you create the constraint after those nodes were in? If not, please post the code of your `createIfNotFound` – FrobberOfBits Oct 04 '15 at 19:15
  • @Stefen : yes on dropping and recreating I do see the error. – lazywiz Oct 07 '15 at 19:16
  • @FrobberOfBits Yes I did create the node after adding the constraint. Unfortunately I got impatient and dumped the code and rewrote it all afresh. Its working fine now. Also I posted on the neo4j cummunity forum and seems like they have found the bug. I will test it by resurrecting my old code and testing this weekend. Once resolved I would post the solution and root cause here. – lazywiz Oct 07 '15 at 19:18
  • Thanks @Stefen and FrobberOfBits, appreciate your interest and suggestions. – lazywiz Oct 07 '15 at 19:18

0 Answers0