Search code examples
node.jsneo4jcyphernode-neo4j

Neo4j match array value with node property


I am trying with this query

MATCH(u:User) WHERE ANY(name IN ['ACB','xYz'] WHERE u.first_name =~ "(?i).*name.*") RETURN u

it is considering (?i).*name.* as static text instead of dynamic value from name IN ['ACB','xYz'].


Solution

  • You can assemble a regex expression using string concatenation. This case however needs some toString hinting:

    MATCH(u:User) WHERE ANY(name IN ['ACB','xYz'] 
        WHERE u.first_name =~ toString("(?i).*" +name +".*")) 
    RETURN u