cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Summary of Node and Relationship Properties

genealogy
Graph Buddy

Had a requirement to summarizes unique properties and thought others might find these queries useful:

MATCH (n)
with DISTINCT labels(n) as nd,apoc.coll.sort(keys(n)) as props
with nd,apoc.coll.dropDuplicateNeighbors(apoc.coll.sort(apoc.coll.flatten(collect(props)))) as pr
return nd as nodes,size(pr) as property_ct, pr as properties order by nodes

MATCH ()-[r]-()
with DISTINCT type(r) as rel,apoc.coll.sort(keys(r)) as props
with rel,apoc.coll.dropDuplicateNeighbors(apoc.coll.sort(apoc.coll.flatten(collect(props)))) as pr
return rel,size(pr) as property_ct, pr as properties order by rel

MATCH (n)
with DISTINCT labels(n) as nd,apoc.coll.sort(keys(n)) as props
with nd,apoc.coll.dropDuplicateNeighbors(apoc.coll.sort(apoc.coll.flatten(collect(props)))) as pr
with nd,pr unwind pr as property
return nd as nodes,property order by nodes,property

MATCH ()-[r]-()
with DISTINCT type(r) as rel,apoc.coll.sort(keys(r)) as props
with rel,apoc.coll.dropDuplicateNeighbors(apoc.coll.sort(apoc.coll.flatten(collect(props)))) as pr
with rel,pr unwind pr as property
return rel as relationships,property order by relationships,property

1 REPLY 1

genealogy
Graph Buddy

These are also useful;

CALL apoc.meta.nodeTypeProperties()

CALL apoc.meta.relTypeProperties()