Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine property value type within a node in neo4j?

Currently - there does not appear to be a way to determine if a property value in a node (or relationship) is an array/collection or a string.

match (n) where isArray(n.myprop) ....

this would be super handy when trying to understand the types of data you are working with relative to your updates and queries. Specifically, if you had situations were you were trying to update property values and needed to know "how" to update them based on how the current values were stored.

like image 900
David Bigelow Avatar asked Nov 28 '14 18:11

David Bigelow


1 Answers

Right now there is nothing built in but it would be a good addition. Feel free to raise an issue on github.

Something like this could help until then?

CREATE ({ a:1,b:"a",c: [1,2,3]})

MATCH (a)
RETURN size(a.a),
CASE a.a
WHEN toInt(a.a)
THEN 'int'
WHEN toFloat(a.a)
THEN 'float'
WHEN toString(a.a)
THEN 'string'
WHEN [x IN a.a | x]
THEN 'coll'
WHEN NULL THEN 'null'
ELSE 'unknown' END , size(a.b), size(a.c)
like image 140
Michael Hunger Avatar answered Nov 03 '22 20:11

Michael Hunger