# Ignoring case using Cypher DSL

**URL:** https://community.neo4j.com/t/ignoring-case-using-cypher-dsl/44786
**Category:** Spring Data Neo4j & Neo4j-OGM
**Created:** [September 22, 2021, 10:11pm UTC](https://community.neo4j.com/t/ignoring-case-using-cypher-dsl/44786 "2021-09-22T22:11:08Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![surjit.bhachu](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/surjit.bhachu/32/3875_2.png) [@surjit.bhachu](https://community.neo4j.com/u/surjit.bhachu)
#### Post date: [September 22, 2021, 10:11pm UTC](https://community.neo4j.com/t/ignoring-case-using-cypher-dsl/44786/1 "2021-09-22T22:11:08Z")

</div>

I'm new to Cypher-DSL and starting to build some dynamic queries in Spring Neo4J.

I see in the documentation that you can use equalsIgnoreCase for Querydsl Predicate

```auto
Predicate predicate = user.firstname.equalsIgnoreCase("dave")
        .and(user.lastname.startsWithIgnoreCase("mathews"));

```

As I want to use projections, how would I do the equalsIgnoreCase for the `key` property value below?

```auto
Node p = Cypher.node("Entity").named("p"); 
        StatementBuilder.OngoingReadingAndReturn cypher = Cypher
        .match(p)
        .where(p.property("key").isEqualTo(Cypher.literalOf(key))) 
        .returning(p);
        return cypher;

```

---

<div class="post-metadata">

### Author: ![akollegger1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/akollegger1/32/14828_2.png) [@akollegger1](https://community.neo4j.com/u/akollegger1)
#### Post date: [September 23, 2021, 7:25am UTC](https://community.neo4j.com/t/ignoring-case-using-cypher-dsl/44786/2 "2021-09-23T07:25:57Z")

</div>

Hi,

I think you can turn a `Predicate` into a Cypher condition which should be acceptable to the `where` clause. Looking at [The Neo4j Cypher-DSL](http://neo4j-contrib.github.io/cypher-dsl/current/#query-dsl-support)

Re-using your two code-snippets, you should be able to do something like:

```auto
Predicate predicate = user.firstname.equalsIgnoreCase("dave")
        .and(user.lastname.startsWithIgnoreCase("mathews"));

Node p = Cypher.node("Entity").named("p"); 
        StatementBuilder.OngoingReadingAndReturn cypher = Cypher
        .match(p)
        .where(Cypher.adapt(predicate).asCondition()) 
        .returning(p);
        return cypher;

```

The challenge is what happens with that specific `equalsIgnoreCase()`, how it is translated into Cypher. _If_ it works, it would have to turn the equalsIgnoreCase into a regular expression in Cypher, as described here: [WHERE - Cypher Manual](https://neo4j.com/docs/cypher-manual/current/clauses/where/#case-insensitive-regular-expressions)

@michael.simons Am I close? 🙂

-ABK

---

<div class="post-metadata">

### Author: ![michael\_simons1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael_simons1/32/5390_2.png) [@michael\_simons1](https://community.neo4j.com/u/michael_simons1)
#### Post date: [September 23, 2021, 7:54am UTC](https://community.neo4j.com/t/ignoring-case-using-cypher-dsl/44786/3 "2021-09-23T07:54:29Z")

</div>

Quite spot on, @abk !

However, you and @surjit.bhachu hit one of the few QueryDSL ops we don't support (`equalsIgnoreCase`), but I am gonna fix that. Until then, this works:

```java
QPerson user = QPerson.person;

Predicate predicate = user.firstName.toLowerCase().eq("dave".toLowerCase())
	.and(user.lastName.startsWithIgnoreCase("mathews"));

Node p = Cypher.node("Entity").named("p");
String cypher = Cypher
	.match(p)
	.where(Cypher.adapt(predicate).asCondition())
	.returning(p)
	.build().getCypher();

assertThat(cypher).isEqualTo("MATCH (p:`Entity`) WHERE toLower(person.firstName) = 'dave' AND toLower(person.lastName) STARTS WITH 'mathews' RETURN p");

```

Thanks you two for using and working with the Cypher-DSL, that's great!

---

<div class="post-metadata">

### Author: ![michael\_simons1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael_simons1/32/5390_2.png) [@michael\_simons1](https://community.neo4j.com/u/michael_simons1)
#### Post date: [September 23, 2021, 7:55am UTC](https://community.neo4j.com/t/ignoring-case-using-cypher-dsl/44786/4 "2021-09-23T07:55:26Z")

</div>

(Oh no, I just duplicated myself by using the Google sign in… Why is this always so hard getting SSO right :( )

---

<div class="post-metadata">

### Author: ![surjit.bhachu](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/surjit.bhachu/32/3875_2.png) [@surjit.bhachu](https://community.neo4j.com/u/surjit.bhachu)
#### Post date: [September 23, 2021, 10:19am UTC](https://community.neo4j.com/t/ignoring-case-using-cypher-dsl/44786/5 "2021-09-23T10:19:04Z")

</div>

Great thanks guys. I'll be posting some more questions while I try to migrate our product to Spring Neo4j 6, bear with me :)
