apoc.meta.nodeTypeProperties过程
|
语法 |
|
||
描述 |
检查整个图数据库,并返回包含其中 |
||
输入参数 |
名称 |
类型 |
描述 |
|
|
|
|
返回参数 |
名称 |
类型 |
描述 |
|
|
节点的类型。 |
|
|
|
节点上的标签。 |
|
|
|
属性名称。 |
|
|
|
该属性包含的类型。 |
|
|
|
该属性是否存在于给定类型的所有节点上。 |
|
|
|
观察到该属性的次数。 |
|
|
|
观察到该标签的次数。 |
|
配置参数
此过程支持以下配置参数
| 名称 | 类型 | 默认 | 描述 |
|---|---|---|---|
|
|
[] |
需要包含的节点标签。默认为包含所有节点标签。 |
|
|
[] |
需要包含的关系类型。默认为包含所有关系类型。 |
|
|
[] |
需要排除的节点标签。默认为包含所有节点标签。 |
|
|
[] |
需要排除的关系类型。默认为包含所有关系类型。 |
|
|
1000 |
采样的节点数量。将 |
|
|
100 |
每个采样节点读取的关系数量。 |
采样 (Sampling)
指定 sample 参数(默认为 1000)以分析数据的子集。
采样以及每个标签的节点计数用于计算跳过值(skip value)。由于此值是使用随机数生成器生成的,因此通过采样方法获得的结果在后续运行中可能会有所不同。
如果数据库包含 500 个标签为 Foo 的节点,则该标签的跳过计数计算如下
每个节点标签的跳过计数是通过生成 (totalNodesForLabel / sample) ± 0.1 之间的随机数来确定的。
采样 10:skipCount = 500 / 10 = 50
得到的跳过计数将在 45 到 55 之间。
采样 50:skipCount = 500 / 50 = 10
得到的跳过计数将在 9 到 11 之间。
采样 100:skipCount = 500 / 100 = 5
得到的跳过计数将为 5。
跳过计数表示在检查一个节点之前跳过的节点数量。例如,跳过计数为 5 时,每 5 个节点检查一次。因此,采样数值越大,采样的节点就越多。
要停止采样,请设置 sample: -1。
| 名称 | 类型 | 默认 | 描述 |
|---|---|---|---|
|
|
[] |
已弃用,请使用 |
|
|
[] |
已弃用,请使用 |
|
|
[] |
已弃用,请使用 |
使用示例
本节中的示例基于以下示例图
CREATE (Keanu:Person {name:'Keanu Reeves', born:1964})
CREATE (TomH:Person {name:'Tom Hanks', born:1956})
CREATE (TheMatrix:Movie {title:'The Matrix', released:1999, tagline:'Welcome to the Real World'})
CREATE (TheMatrixReloaded:Movie {title:'The Matrix Reloaded', released:2003, tagline:'Free your mind'})
CREATE (TheMatrixRevolutions:Movie {title:'The Matrix Revolutions', released:2003, tagline:'Everything that has a beginning has an end'})
CREATE (SomethingsGottaGive:Movie {title:"Something's Gotta Give", released:2003})
CREATE (TheDevilsAdvocate:Movie {title:"The Devil's Advocate", released:1997, tagline:'Evil has its winning ways'})
CREATE (YouveGotMail:Movie {title:"You've Got Mail", released:1998, tagline:'At odds in life... in love on-line.'})
CREATE (SleeplessInSeattle:Movie {title:'Sleepless in Seattle', released:1993, tagline:'What if someone you never met, someone you never saw, someone you never knew was the only someone for you?'})
CREATE (ThatThingYouDo:Movie {title:'That Thing You Do', released:1996, tagline:'In every life there comes a time when that thing you dream becomes that thing you do'})
CREATE (CloudAtlas:Movie {title:'Cloud Atlas', released:2012, tagline:'Everything is connected'})
CREATE (Keanu)-[:ACTED_IN {roles:['Neo']}]->(TheMatrix)
CREATE (Keanu)-[:ACTED_IN {roles:['Neo']}]->(TheMatrixReloaded)
CREATE (Keanu)-[:ACTED_IN {roles:['Neo']}]->(TheMatrixRevolutions)
CREATE (Keanu)-[:ACTED_IN {roles:['Julian Mercer']}]->(SomethingsGottaGive)
CREATE (Keanu)-[:ACTED_IN {roles:['Kevin Lomax']}]->(TheDevilsAdvocate)
CREATE (TomH)-[:ACTED_IN {roles:['Joe Fox']}]->(YouveGotMail)
CREATE (TomH)-[:ACTED_IN {roles:['Sam Baldwin']}]->(SleeplessInSeattle)
CREATE (TomH)-[:ACTED_IN {roles:['Mr. White']}]->(ThatThingYouDo)
CREATE (TomH)-[:ACTED_IN {roles:['Zachry', 'Dr. Henry Goose', 'Isaac Sachs', 'Dermot Hoggins']}]->(CloudAtlas);
我们可以通过运行以下查询,从数据库内容的采样中返回数据库的元数据
CALL apoc.meta.nodeTypeProperties();
| nodeType(节点类型) | nodeLabels | 属性名称 (propertyName) | 属性类型 (propertyTypes) | 强制性 (mandatory) | propertyObservations(属性观察次数) | totalObservations(总观察次数) |
|---|---|---|---|---|---|---|
":`Person`" |
["Person"] |
"name" |
["String"] |
FALSE |
2 |
2 |
":`Person`" |
["Person"] |
"born" |
["Long"] |
FALSE |
2 |
2 |
":`Movie`" |
["Movie"] |
"title" |
["String"] |
FALSE |
9 |
9 |
":`Movie`" |
["Movie"] |
"tagline" |
["String"] |
FALSE |
8 |
9 |
":`Movie`" |
["Movie"] |
"released" |
["Long"] |
FALSE |
9 |
9 |
要返回特定标签子集的元数据,请指定 includeLabels 配置参数。以下示例返回 Person 标签的元数据
CALL apoc.meta.nodeTypeProperties({includeLabels: ["Person"]});
| nodeType(节点类型) | nodeLabels | 属性名称 (propertyName) | 属性类型 (propertyTypes) | 强制性 (mandatory) | propertyObservations(属性观察次数) | totalObservations(总观察次数) |
|---|---|---|---|---|---|---|
":`Person`" |
["Person"] |
"name" |
["String"] |
FALSE |
2 |
2 |
":`Person`" |
["Person"] |
"born" |
["Long"] |
FALSE |
2 |
2 |
我们可以通过指定 sample 参数来控制采样率。以下示例基于每个标签最多采样 3 个节点来返回元数据
CALL apoc.meta.nodeTypeProperties({sample: 3});
| nodeType(节点类型) | nodeLabels | 属性名称 (propertyName) | 属性类型 (propertyTypes) | 强制性 (mandatory) | propertyObservations(属性观察次数) | totalObservations(总观察次数) |
|---|---|---|---|---|---|---|
":`Person`" |
["Person"] |
"name" |
["String"] |
FALSE |
2 |
2 |
":`Person`" |
["Person"] |
"born" |
["Long"] |
FALSE |
2 |
2 |
":`Movie`" |
["Movie"] |
"title" |
["String"] |
FALSE |
3 |
3 |
":`Movie`" |
["Movie"] |
"tagline" |
["String"] |
FALSE |
3 |
3 |
":`Movie`" |
["Movie"] |
"released" |
["Long"] |
FALSE |
3 |
3 |