質問

I'm working with a colleague's database, where in some cases they have stored what should be integer values as strings. Is it possible to convert strings into numeric types in Cypher? If not, could it be added to the feature roadmap?

I want to use Cypher queries to return nodes that have a certain property whose value is greater than 100. My sample queries look like this: (get a list of people who charged the same project for > 100 hours).

match (p1)-[r1:charged_project]->(proj)<-[r2:charged_project]-(p2) 
      where p1 <> p2 and 
      r1.hours > 100 and r2.hours > 100 
      return p1, proj, p2 limit 10;

This results in this error, due to the fact that some of the r1.hours are Strings.

IncomparableValuesException: Don't know how to compare that. 
Left: "16" (String); Right: 100 (Long)

I am aware there's a similar question out there about this - but the solution to that was Integer -> String conversion, which could be accomplished by str(). That's not going to work for me, I think I need the equivalent of java's Long.parseLong.

役に立ちましたか?

解決

Since Neo4j 2.0.3 there is a toInt and a toFloat function for Strings, see http://docs.neo4j.org/chunked/stable/query-functions-scalar.html#functions-toint.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top