apoc.schema.nodes
Procedure APOC Core
CALL apoc.schema.nodes([config]) yield name, label, properties, status, type
Signature
apoc.schema.nodes(config = {} :: MAP?) :: (name :: STRING?, label :: ANY?, properties :: LIST? OF STRING?, status :: STRING?, type :: STRING?, failure :: STRING?, populationProgress :: FLOAT?, size :: INTEGER?, valuesSelectivity :: FLOAT?, userDescription :: STRING?)
Config parameters
The procedure supports the following config parameters:
name | type | default | description |
---|---|---|---|
labels |
List<String> |
[] |
list of labels to retrieve index/constraint information. Default is to include all labels. |
excludeLabels |
List<String> |
[] |
list of labels to exclude from retrieve index/constraint information. Default is to include all labels. |
It’s not possible to evaluate both labels
and excludeLabels
.
In this case, the error Parameters labels and excludeLabels are both valued.
will be thrown.
Output parameters
Name | Type |
---|---|
name |
STRING? |
label |
ANY? |
properties |
LIST? OF STRING? |
status |
STRING? |
type |
STRING? |
failure |
STRING? |
populationProgress |
FLOAT? |
size |
INTEGER? |
valuesSelectivity |
FLOAT? |
userDescription |
STRING? |
Usage Examples
The type
result can have one of the following values:
name | Schema type |
---|---|
"UNIQUENESS" |
Unique node property constraint |
"NODE_PROPERTY_EXISTENCE" |
Node property existence constraint |
"NODE_KEY" |
Node key constraint |
"FULLTEXT" |
Full-text index |
"TEXT" |
Text index |
"RANGE" |
Range index |
"POINT" |
Point index |
"LOOKUP" |
Lookup index |
Given the following schema:
CREATE CONSTRAINT personName FOR (person:Person)
REQUIRE person.name IS UNIQUE;
CREATE CONSTRAINT userId FOR (user:User)
REQUIRE user.id IS UNIQUE;
CREATE FULLTEXT INDEX fullIdx FOR (n:Movie|Book) ON EACH [n.title, n.description];
CREATE POINT INDEX pointIdx FOR (n:Place) ON (n.address);
CREATE TEXT INDEX textIdx FOR (n:Game) ON (n.title);
It is possible to execute the following query:
CALL apoc.schema.nodes()
name | label | properties | status | type | failure | populationProgress | size | valuesSelectivity | userDescription |
---|---|---|---|---|---|---|---|---|---|
":Person(name)" |
"Person" |
["name"] |
"" |
"UNIQUENESS" |
"NO FAILURE" |
0.0 |
0 |
0.0 |
"Constraint( id=8, name='personName', type='UNIQUENESS', schema=(:Person {name}), ownedIndex=7 )" |
":User(id)" |
"User" |
["id"] |
"" |
"UNIQUENESS" |
"NO FAILURE" |
0.0 |
0 |
0.0 |
"Constraint( id=4, name='userId', type='UNIQUENESS', schema=(:User {id}), ownedIndex=3 )" |
":Game(title)" |
"Game" |
["title"] |
"ONLINE" |
"TEXT" |
"NO FAILURE" |
100.0 |
0 |
1.0 |
"Index( id=9, name='textIdx', type='GENERAL TEXT', schema=(:Game {title}), indexProvider='text-2.0' )" |
":Person(name)" |
"Person" |
["name"] |
"ONLINE" |
"BTREE" |
"NO FAILURE" |
100.0 |
0 |
1.0 |
"Index( id=7, name='personName', type='UNIQUE BTREE', schema=(:Person {name}), indexProvider='range-1.0', owningConstraint=8 )" |
":Place(address)" |
"Place" |
["address"] |
"ONLINE" |
"POINT" |
"NO FAILURE" |
100.0 |
0 |
1.0 |
"Index( id=6, name='pointIdx', type='GENERAL POINT', schema=(:Place {address}), indexProvider='point-1.0' )" |
":User(id)" |
"User" |
["id"] |
"ONLINE" |
"BTREE" |
"NO FAILURE" |
100.0 |
0 |
1.0 |
"Index( id=3, name='userId', type='UNIQUE BTREE', schema=(:User {id}), indexProvider='range-1.0', owningConstraint=4 )" |
Please note that the unique node property constraints (i.e. personName
and userId
) return two results,
one for the constraint itself (the rows with type "UNIQUENESS"
)
and one for the index that is created at the same time as the constraint (with type "RANGE"
).
Given the following schema:
CREATE CONSTRAINT node_cons IF NOT EXISTS FOR (bar:Bar) REQUIRE bar.foobar IS NOT NULL;
CREATE CONSTRAINT FOR (f:Test) REQUIRE (f.bar,f.foo) IS NODE KEY;
It is possible to execute the following query:
CALL apoc.schema.nodes()
name | label | properties | status | type | failure | populationProgress | size | valuesSelectivity | userDescription |
---|---|---|---|---|---|---|---|---|---|
":Bar(foobar)" |
"Bar" |
["foobar"] |
"" |
"NODE_PROPERTY_EXISTENCE" |
"NO FAILURE" |
0.0 |
0 |
0.0 |
"Constraint( id=7, name='node_cons', type='NODE PROPERTY EXISTENCE', schema=(:Bar {foobar}) )" |
":Test(bar,foo)" |
"Test" |
["bar", "foo"] |
"" |
"NODE_KEY" |
"NO FAILURE" |
0.0 |
0 |
0.0 |
"Constraint( id=9, name='constraint_d926cedc', type='NODE KEY', schema=(:Test {bar, foo}), ownedIndex=8 )" |
":Test(bar,foo)" |
"Test" |
["bar", "foo"] |
"ONLINE" |
"RANGE" |
"NO FAILURE" |
100.0 |
0 |
1.0 |
"Index( id=8, name='constraint_d926cedc', type='RANGE', schema=(:Test {bar, foo}), indexProvider='range-1.0', owningConstraint=9 )" |
Similarly to unique node property constraints, the node key constraints return two results (with types "NODE_KEY"
and "RANGE"
).
Given a node with a string property larger than 32kb, i.e. (:LabelTest {prop: <LARGE_STRING_MORE_THAN_32_KB>})
,
and the following index:
CREATE INDEX FOR (n:LabelTest) ON (n.prop)
It is possible to execute the following query which will show, in the failure
column, a failure message similar to the command output of SHOW INDEX YIELD failureMessage
:
CALL apoc.schema.nodes()
name | label | properties | status | type | failure | populationProgress | size | valuesSelectivity | userDescription |
---|---|---|---|---|---|---|---|---|---|
":LabelTest(prop)" |
"LabelTest" |
["prop"] |
"FAILED" |
"RANGE" |
"java.lang.IllegalArgumentException: Property value is too large to index, please see index documentation for limitations. Index: Index( id=6, name='index_58741a3d', type='RANGE', schema=(:LabelTest {prop}), indexProvider='range-1.0' ), entity id: 321, property size: 104815, value: [String("2023-06-19T10:14:05.9391146Z apoc.it.core.SchemasEnterpriseFeaturesTest STANDARD_ERROR 2023…. at org.neo4j.kernel.api.index.IndexValueValidator.throwSizeViolationException … |
0.0 |
0 |
1.0 |
"Index( id=6, name='index_58741a3d', type='RANGE', schema=(:LabelTest {prop}), indexProvider='range-1.0' )" |