cancel
Showing results for 
Search instead for 
Did you mean: 

Join the community at Nodes 2022, our free virtual event on November 16 - 17.

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()