apoc.schema.nodes
|
此存储过程不适合在多线程环境下安全运行,因此并行运行时不支持。更多信息请参阅 Cypher 手册 → 并行运行时。 |
语法 |
|
||
描述 |
返回数据库中所有 |
||
输入参数 |
名称 |
类型 |
描述 |
|
|
|
|
返回参数 |
名称 |
类型 |
描述 |
|
|
索引或约束的生成名称。 |
|
|
|
与约束或索引关联的标签。 |
|
|
|
与约束或索引关联的属性键。 |
|
|
|
约束或索引的状态。 |
|
|
|
索引或约束的类型。 |
|
|
|
是否发生故障。 |
|
|
|
约束或索引填充的百分比。 |
|
|
|
给定约束或索引中的条目数。 |
|
|
|
0.0到1.0之间的比率,表示从采样中看到的唯一值数量。 |
|
|
|
约束或索引的描述符。 |
|
签名
apoc.schema.nodes(config = {} :: MAP) :: (name :: STRING, label :: ANY, properties :: LIST<STRING>, status :: STRING, type :: STRING, failure :: STRING, populationProgress :: FLOAT, size :: INTEGER, valuesSelectivity :: FLOAT, userDescription :: STRING)
配置参数
此存储过程支持以下配置参数
| name | type | 默认值 | 描述 |
|---|---|---|---|
labels |
LIST<STRING> |
[] |
要检索索引/约束信息的标签列表。默认包含所有标签。 |
excludeLabels |
LIST<STRING> |
[] |
要从检索索引/约束信息中排除的标签列表。默认包含所有标签。 |
不能同时评估 labels 和 excludeLabels。在这种情况下,将抛出错误 Parameters labels and excludeLabels are both valued.。
输出参数
| 名称 | 类型 |
|---|---|
name |
STRING |
label |
ANY |
properties |
LIST<STRING> |
status |
STRING |
type |
STRING |
failure |
STRING |
populationProgress |
FLOAT |
size |
INTEGER |
valuesSelectivity |
FLOAT |
userDescription |
STRING |
使用示例
type 结果可以具有以下值之一
| name | 模式类型 |
|---|---|
"UNIQUENESS" |
唯一节点属性约束 |
"NODE_PROPERTY_EXISTENCE" |
节点属性存在约束 |
"NODE_KEY" |
节点键约束 |
"FULLTEXT" |
全文索引 |
"TEXT" |
文本索引 |
"RANGE" |
范围索引 |
"POINT" |
点索引 |
"LOOKUP" |
查找索引 |
给定以下模式
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);
可以执行以下查询
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='TEXT', schema=(:Game {title}), indexProvider='text-2.0' )" |
":Person(name)" |
"Person" |
["name"] |
"ONLINE" |
"RANGE" |
"NO FAILURE" |
100.0 |
0 |
1.0 |
"Index( id=7, name='personName', type='RANGE', 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='POINT', schema=(:Place {address}), indexProvider='point-1.0' )" |
":User(id)" |
"User" |
["id"] |
"ONLINE" |
"RANGE" |
"NO FAILURE" |
100.0 |
0 |
1.0 |
"Index( id=3, name='userId', type='RANGE', schema=(:User {id}), indexProvider='range-1.0', owningConstraint=4 )" |
请注意,唯一节点属性约束(即 personName 和 userId)返回两个结果:一个用于约束本身(类型为 "UNIQUENESS" 的行),另一个用于与该约束同时创建的索引(类型为 "RANGE")。
给定以下模式
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;
可以执行以下查询
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 )" |
与唯一节点属性约束类似,节点键约束也返回两个结果(类型分别为 "NODE_KEY" 和 "RANGE")。
给定一个字符串属性大于 32KB 的节点,例如 (:LabelTest {prop: <LARGE_STRING_MORE_THAN_32_KB>}),以及以下索引
CREATE INDEX FOR (n:LabelTest) ON (n.prop)
可以执行以下查询,它将在 failure 列中显示一个类似于 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' )" |