neo4j/community — Issue #107: Multiple regular expressions in single WHERE clause produces empty result
Author: systay
Created: 2011-11-17 18:17:34+00:00
State: open
Labels: bug, cypher

This is using 1.5 GA.

I think I found a bug (or unsupported feature) in how regular
expressions used in where clauses work in Cypher queries.

It doesn't look like having multiple regular expression conditions
in a where clause back to back works too well.

Here's an example that works:

start n = node(1) match (n)-[:KNOWS]->(k) where k.a =~ /foo.*/ return k

Returns all connected nodes where property a starts with "foo".

Here's an example that doesn't work:

start n = node(1) match (n)-[:KNOWS]->(k) where k.a =~ /foo.*/ or k.b
=~ /foo.*/ return k

This will always return an empty result. So will if I change or to and.

Here's an example that does work:

start n = node(1) match (n)-[:KNOWS]->(k) where k.a =~ /foo.*/ or k.a
= "foo" or k.b =~ /foo.*/ return k

The introduction of a non-regular expression condition makes the
query work as intended.

This one does not work:

start n = node(1) match (n)-[:KNOWS]->(k) where k.a =~ /foo.*/ or k.b
=~ /foo.*/ or k.a = "foo" return k

Looks like a bug to me, and seems to be caused by where clauses
with more than one regular expression conditions next to each other.