I have a couple of nodes sharing a property with a numeric value. I would like to filter on this property using a reular expression. Is this possible using the Cypher Query Language?
Example:
A { num: 3 }
B { num: 12 }
C { num: 532 }
D { num: 1423 }
How can I get all nodes where the num property contains the digit 3 (should return A, C and D). I’ve tried something like n.num =~ '3', but it results in an error (“java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String)“)
Any ideas?
With this, you are trying to apply a RegExp to a property of type Long, which is not valid. Defining the node properties as strings will work, see http://tinyurl.com/bqoq62q
Otherwise, there is support for autocasting coming up, so you could (in future versions of Cypher) do
where (node.num+'') =~ '3'to do this even with a Long. But not now.