Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-23-2020 10:42 AM
If I want a traditional table of properties from a node, I know I can do:
RETURN n.prop1, n.prop2, n.prop,
etc.
What I'd like to do is something like:
RETURN n.*
to return all the property values (as a short hand).
I don't want RETURN n
as it returns a Map, which is harder to for me to skim visually for patterns.
I've google what I want, and there are some close matches, but I haven't been able to find exactly what I want. I've also tried various permutations of UNWIND
, keys()
etc.
I realize this could be a mess if the nodes have radically dissimilar property names.... but my data is very regular. I'd be happy to use the keys()
function on one node as the set of properties for all my nodes that I'm matching.
12-23-2020 11:20 AM
@clem, if you need to retrieve only the properties of a node; something like RETURN n.*
, you can try with RETURN properties(n)
and see if it will meet your need.
it will return the keys of the node associated with their values.
12-23-2020 12:12 PM
Nope. That's not what I want.
If I do:
match(p:Person {name:"Ed Harris"}) return properties(p)
I get:
╒════════════════════════════════╕
│"properties(p)" │
╞════════════════════════════════╡
│{"born":1950,"name":"Ed Harris"}│
└────────────────────────────────┘
I want the equivalent of:
match(p:Person {name:"Ed Harris"}) return p.name, p.born
╒═══════════╤════════╕
│"p.name" │"p.born"│
╞═══════════╪════════╡
│"Ed Harris"│1950 │
└───────────┴────────┘
but not having to manually enter all the property names.
12-24-2020 06:52 AM
Hi @clem,
There is no PIVOT functionality in neo4j. As an alternate solution I have created a python function, that can take any node name (or all if NONE provided).
Python jupyter notebook file -> neo4j_pivot.ipynb
Github URL -> neo4j/community/pivot_neo4j at master · dominicvivek06/neo4j · GitHub
Note - Try Exception not implemented in python as of now
The Cypher query to get key, value pair for the node is
MATCH (n)
UNWIND keys(n) as property
RETURN labels(n) as node,id(n) as node_id , property, n[property] as value;
Blog Post -> URL
Let me know how I can assist further.
All the sessions of the conference are now available online