List properties of a label/relationship

Hello, I need to list all the possibile properties of all the nodes of type "CI"; next I need to list of properties of relationship "USES". Can you please help?

I find examples, but the use some APOC.MAP functions that my Neo refuses to recognize.

Thank you

Hello @dario.piantanida :slight_smile:

Without APOC

  • Nodes:
MATCH (n:CI)
WITH REDUCE(output = [], r IN collect(keys(n)) | output + r) AS flat
UNWIND flat AS item
RETURN COLLECT(DISTINCT item) AS keys
  • Relations:
MATCH ()-[n:USES]->()
WITH REDUCE(output = [], r IN collect(keys(n)) | output + r) AS flat
UNWIND flat AS item
RETURN COLLECT(DISTINCT item) AS keys

With APOC

  • Nodes:
MATCH (n:CI)
RETURN apoc.coll.toSet(apoc.coll.flatten(collect(keys(n)))) AS keys
  • Relations:
MATCH ()-[n:USES]->()
RETURN apoc.coll.toSet(apoc.coll.flatten(collect(keys(n)))) AS keys

Don't forget to check in the neo4j.conf file these settings:

dbms.security.procedures.unrestricted=apoc.*
dbms.security.procedures.whitelist=apoc.*

You can also have a look at the properties() function if you want to get the values instead of the keys.

Regards,
Cobra

Macinando, ho trovato questa che sembra soddisfacente, che dici?

call db.schema.nodeTypeProperties() yield nodeType, nodeLabels, propertyName, propertyTypes
where "CI" in nodeLabels
return nodeType, propertyName, propertyTypes

It's a good option, I forgot this one :slight_smile:
Choose the one you prefer :slight_smile:

Sorry, I wrote in Italian as I didn't remember I was on an English community! :rofl:

Thanks for your support!