I've got a property quantity
on our Product
-nodes and am looking to do a cypher query that gives me all nodes with quantity = 20
... problem is that quantity is stored as a string in neo4j. Is there a way to cast the property to integer in the cypher query?
// This fails to find the required nodes
MATCH (p:Product) WHERE p.quantity = 20;
// This finds them
MATCH (p:Product) WHERE p.quantity = "20";
// I would like to do this
MATCH (p:Product) WHERE INT(p.quantity) = 20;
PS: this is a really simplified usecase, we don't really have products and quantities but are just faced with existing neo4j data that has integer values stored as strings, and we would like to do some matches on these strings
You can do it the other way round.
should also work with params.
or even with inline property matches
I too have been faced with that problem earlier. As far as I found out, it was not possible to do that conversion directly in cypher. I used a small Java script (using the standard Java API) to change the data types of the stored values. This is a couple of months ago though, so it might have changed with the 2.0 version.