I have stored a double (-0.1643) as string ("-0.1643") in a property on a neo4j relationship.
If I try to filter on this value with a numeric comparison:
MATCH (n1:Node)-[r:RELATION]-(n2:Node)
WHERE r.number < -0.1 RETURN n1, n2
Cypher throws an error:
Don't know how to compare that. Left: "-0.1643" (String); Right: -0.1 (Double)
Neo.ClientError.Statement.InvalidSyntax
Obviously, I could store the data as a numeric value. But is it possible to convert the string to double in cypher? Something like:
MATCH (n1:Node)-[r:RELATION]-(n2:Node)
WHERE as.double(r.number) < -0.1 RETURN n1, n2
Check out release 2.0.2. It added to type functions, "toInt, toFloat, toStr". It looks like toDouble doesn't exist, but perhaps float is precise enough for you?
http://www.neo4j.org/release-notes#2.0.2
you can use this:
RETURN toFloat("0.0125")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With