'Can't create unique constraint in Neo4J
I am attempt to create a constraint like this:
CREATE CONSTRAINT ON (a:forecast) ASSERT a.match IS UNIQUE
but I get this error:
Unable to create Constraint( name='constraint_9615361a', type='UNIQUENESS', schema=(:forecast {match}) ):
I have the Neo4J community edition 4.2.3, but judging by the documentation I should be allowed to create this type of constraint. What gives?
Solution 1:[1]
You can check if there is uniqueness on forecast {match} by running this.
MATCH (a:forecast)
RETURN a.match, count(*) LIMIT 5
If you see a value > 1 in count() then forecast.match is not unique.
Note: count() is sorting in descending order in my desktop. In case it is not, then run below:
MATCH (a:forecast)
WITH a.match as match, count(*) as cnt
RETURN match, cnt ORDER by cnt DESC LIMIT 5
Solution 2:[2]
Late reply, but still.
I was struck by the same error now (with 4.4.3) and it was lack of free space on drive.
Wasted half an hour, digging in absolutely wrong direction. I create database with --skip-duplicate-nodes=true flag, so of course there couldn't be any duplicates.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 |
