Running a case-insensitive cypher query

匿名 (未验证) 提交于 2019-12-03 02:06:01

问题:

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(*)  match n-[]->m  where (m.name="Neo")  return m

it returns one row. But when I type into this:

start n=node(*)  match n-[]->m  where (m.name="neo")  return m

it does not return anything; because the name is saved as "Neo". Is there a simple way to run case-insensitive queries?

回答1:

Yes, by using case insensitive regular expressions:

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

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



回答2:

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())     .Results     .FirstOrDefault();


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!