Neo4j / Cypher: convert string to double

I saved the double (-0.1643) as a string ("-0.1643") in the neo4j property.

If I try to filter this value using a numerical comparison:

MATCH (n1:Node)-[r:RELATION]-(n2:Node) WHERE r.number < -0.1 RETURN n1, n2 

Cypher gives an error message:

 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 a string to double in cypher? Something like:

 MATCH (n1:Node)-[r:RELATION]-(n2:Node) WHERE as.double(r.number) < -0.1 RETURN n1, n2 
+7
neo4j cypher
source share
2 answers

Check out release 2.0.2. He added to functions like "toInt, toFloat, toStr". Double doesn't seem to exist, but is it possible to swim accurately enough for you?

http://www.neo4j.org/release-notes#2.0.2

+4
source share

you can use this:

RETURN toFloat ("0.0125")

+2
source share

All Articles