Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-03-2022 12:51 PM
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
01-03-2022 09:38 PM
These are also useful;
CALL apoc.meta.nodeTypeProperties()
CALL apoc.meta.relTypeProperties()
All the sessions of the conference are now available online