Jonathan vE
Jonathan vE

Reputation: 71

Discovering node properties in neo4j grap db

I'm discovering a new graph data model in Neo4j and I was wondering how to list all the possible node properties but not their value if possible.

For the relations, I found this very handy generic cypher query :

start n=node(*)
match n-[r]-m
return distinct type(r)

which return a useful list of properties you can start to use to query more specifically the graph:

==> +------------+
==> | type(r)    |
==> +------------+
==> | "RATED"    |
==> | "FRIEND"   |
==> | "DIRECTED" |
==> | "ACTS_IN"  |
==> +------------+
==> 4 rows
==> 0 ms
==>

Is there any function/expression that allows to do this but for the node properties ?

Thanks

Upvotes: 7

Views: 571

Answers (2)

Vishal Ganjare
Vishal Ganjare

Reputation: 110

To list all the properties of nodes in graph DB, you can try using following cypher:

match (n) 
WITH distinct keys(n) as properties 
UNWIND properties as property 
return distinct property

Thanks, Vishal

Upvotes: 0

type() does not return relationship properties, but the relationship type.

Both nodes and relationships can have properties, but only relationships can have a type.

Upvotes: 2

Related Questions