|
drops all other existing indexes and constraints when |
|
get all indexes and constraints information for all the node labels in your database, in optional config param could be define a set of labels to include or exclude |
|
return all the constraint information for all the relationship types in your database, in optional config param could be define a set of types to include or exclude |
|
return the constraints existence on node |
|
return the constraints existence on relationship |
To drop or create index or constraint, you can use the following procedure:
CALL apoc.schema.assert({indexLabel:[[indexKeys]], ...}, {constraintLabel:[constraintKeys], ...}, dropExisting : true) yield label, key, keys, unique, action
Where the outputs are:
To retrieve indexes and constraints information for all the node labels in your database, you can use the following procedure:
CALL apoc.schema.nodes() yield name, label, properties, status, type
Where the outputs are:
To retrieve the constraint information for all the relationship types in your database, you can use the following procedure:
CALL apoc.schema.relationships() yield name, type, properties, status
Where the outputs are:
Config optional param is a map and its possible values are:
Exclude has more power than include, so if excludeLabels and labels are both valued, procedure considers excludeLabels only, the same for relationships.
CALL apoc.schema.nodes({labels:['Book']}) yield name, label, properties, status, type
N.B. Constraints for property existence on nodes and relationships are available only for the Enterprise Edition.
To retrieve the index existence on node, you can use the following user function:
RETURN apoc.schema.node.indexExists(labelName, propertyNames)
The output return the index existence on node is present or not
To retrieve if the constraint exists on node, you can use the following user function:
RETURN apoc.schema.node.constraintExists(labelName, propertyNames)
The output return the constraint existence on node.
To retrieve if the constraint exists on relationship, you can use the following user function:
RETURN apoc.schema.relationship.constraintExists(type, propertyNames)
The output return the constraint on the relationship is present or not
When you:
CALL apoc.schema.assert({Foo:['bar']},null)
you will receive this result:
When you:
CALL apoc.schema.assert(null,{Foo:['bar']})
you will receive this result:
When you:
CALL apoc.schema.assert(null,null)
you will receive this result:
Given the following cypher statements:
CREATE CONSTRAINT ON (bar:Bar) ASSERT exists(bar.foobar)
CREATE CONSTRAINT ON (bar:Bar) ASSERT bar.foo IS UNIQUE
CREATE INDEX ON :Person(name)
CREATE INDEX ON :Publication(name)
CREATE INDEX ON :Source(name)
When you
CALL apoc.schema.nodes()
you will receive this result:
Given the following cypher statements:
CREATE CONSTRAINT ON ()-[like:LIKED]-() ASSERT exists(like.day)
CREATE CONSTRAINT ON ()-[starred:STARRED]-() ASSERT exists(starred.month)
When you
CALL apoc.schema.relationships()
you will receive this result:
Given the previous index definitions, running this statement:
RETURN apoc.schema.node.indexExists("Publication", ["name"])
produces the following output:
Given the previous constraint definitions, running this statement:
RETURN apoc.schema.node.constraintExists("Bar", ["foobar"])
produces the following output:
If you want to check if a constraint exists for a relationship you can run this statement:
RETURN apoc.schema.relationship.constraintExists('LIKED', ['day'])
and you get the following result: