I'm trying to list all of the properties for a set of nodes.
Match (n:"Indicator")
return properties(n), ID(n)
I'm unsure of the syntax and couldn't find the answer in the refcard or docs.
I'm trying to list all of the properties for a set of nodes.
Match (n:"Indicator")
return properties(n), ID(n)
I'm unsure of the syntax and couldn't find the answer in the refcard or docs.
In Neo4j version 3.0.0 you may do:
Match (n:Indicator) return properties(n), ID(n)
To return the ID and properties of nodes.
At the moment you can't do this using cypher but it is on the top five on the ideas board.
MATCH (n)
RETURN DISTINCT keys(n), size(keys(n))
ORDER BY size(keys(n)) DESC
Properties(n) works if you need the properties of the node with the key and value, but if you only need to see the properties name's in a easy way you can do this. Example:
MATCH (n:Indicator) return ID(n), keys(n), size(keys(n))
Results: Results from Neo4j browser
You can quit ID(n) and size(keys(n)) without problem but is good if you need to identify a node that dont have the required properties or is not complete.
Also you can use a DISTINCT if you have generic and repetitive properties on the same type of Node like this.
MATCH (n:Indicator) return DISTINCT ID(n), keys(n), size(keys(n))
As I have said this also works without problems and give you the array of properties that you need.
MATCH (n:Indicator) return keys(n)
Result only returning keys
But you can resume this long list of results, with a DISTINCT
MATCH (n:Indicator) return DISTINCT keys(n)
Result with only the differents lists of properties that the Node (n) have
MATCH (n:Label)
WITH DISTINCT(keys(n)) as key_sets
UNWIND(key_sets) as keys
RETURN DISTINCT(keys) as key
This will return a clean list of distinct keys
If you have APOC installed, I use this to get a distinct list of all node property combinations:
MATCH (n)
RETURN DISTINCT apoc.coll.sort(keys(n)) as props
,size(keys(n)) as key_size
Note: you don't have to use APOC, but if you don't you'll get duplicates where values are same, but ordering is different, so sorting combines them
I know this post is old, but when I had a similar question, I found the command below to be the solution that returned all the information I needed, which was to list out the properties for each node in the database, and include the property type(s) of each value for each node:
CALL db.schema.nodeTypeProperties()
Additionally, you can do the same thing for relationships:
CALL db.schema.relTypeProperties()
The nice part is that this will work with cypher shell and does not require APOC to be installed.
in the case where the keys are returned in different orders, this does the trick:
MATCH (n)
UNWIND keys(n) AS allProps
RETURN COLLECT(DISTINCT allProps) as distinctProps
© 2022 - 2024 — McMap. All rights reserved.