Running a case-insensitive cypher query

前端 未结 4 907
生来不讨喜
生来不讨喜 2020-12-14 00:08

Is it possible to run a case-insensitive cypher query on neo4j?

Try that: http://console.neo4j.org/

When I type into this:

start n=node(*) 
m         


        
相关标签:
4条回答
  • 2020-12-14 00:21

    Another way would be:

    WHERE LOWER(m.Name) = LOWER("Neo")
    

    And if you are using the Neo4j Client (.NET):

    Client.Cypher.Match("(m:Entity)")
        .Where("LOWER(m.Name) = LOWER({name})")
        .WithParam("name", inputName)
        .Return(m => m.As<Entity>())
        .Results
        .FirstOrDefault();
    
    0 讨论(0)
  • 2020-12-14 00:22

    Yes, by using case insensitive regular expressions:

    WHERE m.name =~ '(?i)neo'
    

    https://neo4j.com/docs/cypher-manual/current/clauses/where/#case-insensitive-regular-expressions

    0 讨论(0)
  • 2020-12-14 00:26

    You can pass a parameter to the case insensitive regular expression like:

    WHERE m.name =~'(?i)({param})

    0 讨论(0)
  • 2020-12-14 00:30

    If anybody is looking on how to do this with a parameter, I managed to do it like this.

    query = "{}{}{}".format('Match (n) WHERE n.pageName =~ "'"(?i)", name, '" RETURN n')
    

    and "name" is the variable or your parameter

    0 讨论(0)
提交回复
热议问题