Running a case-insensitive cypher query
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?
neo4j case-insensitive cypher
add a comment |
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?
neo4j case-insensitive cypher
add a comment |
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?
neo4j case-insensitive cypher
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?
neo4j case-insensitive cypher
neo4j case-insensitive cypher
asked Nov 18 '12 at 10:23
gzggzg
62541634
62541634
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
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
Link is dead now. It is shifted to http://neo4j.com/docs/developer-manual/current/#query-general. Though your answer contains the solution, it will be better to update the link for someone may end up clicking on it.
– Gandalf
Jul 21 '16 at 8:35
=~ operator does not use Indexes
– Abhi
Apr 12 '17 at 11:23
2
how can I pass parameter here?'(?i)$param'
and'(?!)'+$param
doesn't work
– vladkras
Nov 21 '17 at 10:22
add a comment |
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();
This solution is easier to apply for parameter
– thangdc94
Mar 9 '18 at 7:44
@rotgers Wouldn't using the LOWER() function affect index lookups defined on the actual string?
– Partha
Aug 25 '18 at 1:33
add a comment |
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
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f13439278%2frunning-a-case-insensitive-cypher-query%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
Link is dead now. It is shifted to http://neo4j.com/docs/developer-manual/current/#query-general. Though your answer contains the solution, it will be better to update the link for someone may end up clicking on it.
– Gandalf
Jul 21 '16 at 8:35
=~ operator does not use Indexes
– Abhi
Apr 12 '17 at 11:23
2
how can I pass parameter here?'(?i)$param'
and'(?!)'+$param
doesn't work
– vladkras
Nov 21 '17 at 10:22
add a comment |
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
Link is dead now. It is shifted to http://neo4j.com/docs/developer-manual/current/#query-general. Though your answer contains the solution, it will be better to update the link for someone may end up clicking on it.
– Gandalf
Jul 21 '16 at 8:35
=~ operator does not use Indexes
– Abhi
Apr 12 '17 at 11:23
2
how can I pass parameter here?'(?i)$param'
and'(?!)'+$param
doesn't work
– vladkras
Nov 21 '17 at 10:22
add a comment |
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
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
edited Jan 16 '17 at 13:49
Frank S. Thomas
3,85322146
3,85322146
answered Nov 18 '12 at 10:54
Volker PacherVolker Pacher
1,447158
1,447158
2
Link is dead now. It is shifted to http://neo4j.com/docs/developer-manual/current/#query-general. Though your answer contains the solution, it will be better to update the link for someone may end up clicking on it.
– Gandalf
Jul 21 '16 at 8:35
=~ operator does not use Indexes
– Abhi
Apr 12 '17 at 11:23
2
how can I pass parameter here?'(?i)$param'
and'(?!)'+$param
doesn't work
– vladkras
Nov 21 '17 at 10:22
add a comment |
2
Link is dead now. It is shifted to http://neo4j.com/docs/developer-manual/current/#query-general. Though your answer contains the solution, it will be better to update the link for someone may end up clicking on it.
– Gandalf
Jul 21 '16 at 8:35
=~ operator does not use Indexes
– Abhi
Apr 12 '17 at 11:23
2
how can I pass parameter here?'(?i)$param'
and'(?!)'+$param
doesn't work
– vladkras
Nov 21 '17 at 10:22
2
2
Link is dead now. It is shifted to http://neo4j.com/docs/developer-manual/current/#query-general. Though your answer contains the solution, it will be better to update the link for someone may end up clicking on it.
– Gandalf
Jul 21 '16 at 8:35
Link is dead now. It is shifted to http://neo4j.com/docs/developer-manual/current/#query-general. Though your answer contains the solution, it will be better to update the link for someone may end up clicking on it.
– Gandalf
Jul 21 '16 at 8:35
=~ operator does not use Indexes
– Abhi
Apr 12 '17 at 11:23
=~ operator does not use Indexes
– Abhi
Apr 12 '17 at 11:23
2
2
how can I pass parameter here?
'(?i)$param'
and '(?!)'+$param
doesn't work– vladkras
Nov 21 '17 at 10:22
how can I pass parameter here?
'(?i)$param'
and '(?!)'+$param
doesn't work– vladkras
Nov 21 '17 at 10:22
add a comment |
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();
This solution is easier to apply for parameter
– thangdc94
Mar 9 '18 at 7:44
@rotgers Wouldn't using the LOWER() function affect index lookups defined on the actual string?
– Partha
Aug 25 '18 at 1:33
add a comment |
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();
This solution is easier to apply for parameter
– thangdc94
Mar 9 '18 at 7:44
@rotgers Wouldn't using the LOWER() function affect index lookups defined on the actual string?
– Partha
Aug 25 '18 at 1:33
add a comment |
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();
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();
edited Jan 5 '17 at 16:01
answered Jan 5 '17 at 15:46
rotgersrotgers
1,1461920
1,1461920
This solution is easier to apply for parameter
– thangdc94
Mar 9 '18 at 7:44
@rotgers Wouldn't using the LOWER() function affect index lookups defined on the actual string?
– Partha
Aug 25 '18 at 1:33
add a comment |
This solution is easier to apply for parameter
– thangdc94
Mar 9 '18 at 7:44
@rotgers Wouldn't using the LOWER() function affect index lookups defined on the actual string?
– Partha
Aug 25 '18 at 1:33
This solution is easier to apply for parameter
– thangdc94
Mar 9 '18 at 7:44
This solution is easier to apply for parameter
– thangdc94
Mar 9 '18 at 7:44
@rotgers Wouldn't using the LOWER() function affect index lookups defined on the actual string?
– Partha
Aug 25 '18 at 1:33
@rotgers Wouldn't using the LOWER() function affect index lookups defined on the actual string?
– Partha
Aug 25 '18 at 1:33
add a comment |
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
add a comment |
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
add a comment |
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
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
edited Nov 21 '18 at 12:54


Suraj Rao
23.2k85770
23.2k85770
answered Nov 21 '18 at 12:47


Mursy AlguineedyMursy Alguineedy
112
112
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f13439278%2frunning-a-case-insensitive-cypher-query%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown