user2449952
user2449952

Reputation: 661

Neo4j indexing and unique constraint

Neo4j doesn't allow Index and Unique constraint on same property against a label. Does it mean ?

a) Unique Constraint is already indexed

b) Indexed property can have duplicate value across different node.

Upvotes: 5

Views: 2660

Answers (2)

FylmTM
FylmTM

Reputation: 2007

a) Unique Constraint is already indexed
Yes.

b) Indexed property can have duplicate value across different nodes.
Yes, if only index (without constraint) is added to that property.

You can find more info here.

Important note:

Note that adding a uniqueness constraint on a property will also add an index on that property, so you cannot add such an index separately. Cypher will use that index for lookups just like other indexes. If you drop a constraint and still want an index on the property, you will have to create the index.

Upvotes: 5

Luanne
Luanne

Reputation: 19373

Yes, (a) is true because creating a unique constraint adds an index on the property used in the constraint.

(b) is also true if there is no unique constraint defined on the property.

Upvotes: 9

Related Questions