apoc.meta.relTypeProperties
Procedure
apoc.meta.relTypeProperties(config MAP<STRING, ANY>)
- examines the full graph and returns a table of metadata with information about the RELATIONSHIP
values therein.
This procedure is not considered safe to run from multiple threads. It is therefore not supported by the parallel runtime (introduced in Neo4j 5.13). For more information, see the Cypher Manual → Parallel runtime. |
Signature
apoc.meta.relTypeProperties(config = {} :: MAP) :: (relType :: STRING, sourceNodeLabels :: LIST<STRING>, targetNodeLabels :: LIST<STRING>, propertyName :: STRING, propertyTypes :: LIST<STRING>, mandatory :: BOOLEAN, propertyObservations :: INTEGER, totalObservations :: INTEGER)
Config parameters
This procedure supports the following config parameters:
Name | Type | Default | Description |
---|---|---|---|
includeLabels |
LIST<STRING> |
[] |
Node labels to include. Default is to include all node labels. |
includeRels |
LIST<STRING> |
[] |
Relationship types to include. Default is to include all relationship types. |
excludeLabels |
LIST<STRING> |
[] |
Node labels to exclude. Default is to include all node labels. |
excludeRels |
LIST<STRING> |
[] |
Relationship types to exclude. Default is to include all relationship types. |
sample |
INTEGER |
1000 |
Number of nodes to skip, e.g. a sample of 1000 will read every 1000th node. |
maxRels |
INTEGER |
100 |
Number of relationships to read per sampled node. |
Name | Type | Default | Description |
---|---|---|---|
labels |
LIST<STRING> |
[] |
Deprecated, use |
rels |
LIST<STRING> |
[] |
Deprecated, use |
excludes |
LIST<STRING> |
[] |
Deprecated, use |
Output parameters
Name | Type |
---|---|
relType |
STRING |
sourceNodeLabels |
LIST<STRING> |
targetNodeLabels |
LIST<STRING> |
propertyName |
STRING |
propertyTypes |
LIST<STRING> |
mandatory |
BOOLEAN |
propertyObservations |
INTEGER |
totalObservations |
INTEGER |
Usage Examples
The examples in this section are based on the following sample graph:
CREATE (Keanu:Person {name:'Keanu Reeves', born:1964})
CREATE (TomH:Person {name:'Tom Hanks', born:1956})
CREATE (LillyW:Person {name:'Lilly Wachowski', born:1967})
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)
CREATE (LillyW)-[:DIRECTED]->(TheMatrix);
We can return the metadata of the database from a sample of the database contents, by running the following query:
CALL apoc.meta.relTypeProperties();
relType | sourceNodeLabels | targetNodeLabels | propertyName | propertyTypes | mandatory | propertyObservations | totalObservations |
---|---|---|---|---|---|---|---|
":`ACTED_IN`" |
["Person"] |
["Movie"] |
"roles" |
["StringArray"] |
FALSE |
9 |
9 |
":`DIRECTED`" |
["Person"] |
["Movie"] |
NULL |
NULL |
FALSE |
0 |
1 |
We can return metadata for a subset of relationship types by specifying the rels
config parameter.
The following returns the metadata for the ACTED_IN
label:
CALL apoc.meta.relTypeProperties({rels: ["ACTED_IN"]});
relType | sourceNodeLabels | targetNodeLabels | propertyName | propertyTypes | mandatory | propertyObservations | totalObservations |
---|---|---|---|---|---|---|---|
":`ACTED_IN`" |
["Person"] |
["Movie"] |
"roles" |
["StringArray"] |
FALSE |
9 |
9 |
We can control the number of relationships sampled by specifying the maxRels
parameter.
The following returns metadata based on sampling up to 3 relationships per relationship type:
CALL apoc.meta.relTypeProperties({maxRels: 3});
relType | sourceNodeLabels | targetNodeLabels | propertyName | propertyTypes | mandatory | propertyObservations | totalObservations |
---|---|---|---|---|---|---|---|
":`ACTED_IN`" |
["Person"] |
["Movie"] |
"roles" |
["StringArray"] |
FALSE |
3 |
9 |
":`DIRECTED`" |
["Person"] |
["Movie"] |
NULL |
NULL |
FALSE |
0 |
1 |