# Case insensitive query for a user filter

**URL:** https://community.neo4j.com/t/case-insensitive-query-for-a-user-filter/8793
**Category:** Cypher
**Tags:** neo4j-driver, aws, cypher
**Created:** [July 15, 2019, 5:27pm UTC](https://community.neo4j.com/t/case-insensitive-query-for-a-user-filter/8793 "2019-07-15T17:27:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nickhall122](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/nickhall122/32/4173_2.png) [@nickhall122](https://community.neo4j.com/u/nickhall122)
#### Post date: [July 15, 2019, 5:27pm UTC](https://community.neo4j.com/t/case-insensitive-query-for-a-user-filter/8793/1 "2019-07-15T17:27:35Z")

</div>

I'm using neo4j-driver inside of a lambda function. I found the way to run a case _insensitive_ query using regex by adding WHERE m.name =~ '(?i)neo'. This works when I'm not using a parameter. I've tried all of the ways in the following article, but haven't found the special combo that makes it work. Should I be using a where or should I be using =~ with .\* and \*.?

> <https://stackoverflow.com/questions/13439278/running-a-case-insensitive-cypher-query>

```auto
FilteredUserList: (root, args, context) => {
      return new Promise((resolve, reject) => {
        let session = driver.session();
        let params = { cognitoId: args.cognitoId, textInput: args.textInput };
        let query = `
                MATCH (user:User)
                WHERE user.firstName CONTAINS $textInput OR user.lastName CONTAINS $textInput OR user.email CONTAINS $textInput
                RETURN user
                ;`;

```

---

<div class="post-metadata">

### Author: ![andrew\_bowman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/andrew_bowman/32/73_2.png) [@andrew\_bowman](https://community.neo4j.com/u/andrew_bowman)
#### Post date: [July 15, 2019, 6:32pm UTC](https://community.neo4j.com/t/case-insensitive-query-for-a-user-filter/8793/2 "2019-07-15T18:32:00Z")

</div>

For this type of thing you should probably use the [fulltext schema index](https://neo4j.com/docs/cypher-manual/current/schema/index/#schema-index-fulltext-search), something we added in 3.5.x for this type of thing. You'll need to create it and query it through procedures (see the linked docs) but it should allow for case insensitive querying (by default, no need for the regex).

---

<div class="post-metadata">

### Author: ![nickhall122](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/nickhall122/32/4173_2.png) [@nickhall122](https://community.neo4j.com/u/nickhall122)
#### Post date: [August 8, 2019, 6:34pm UTC](https://community.neo4j.com/t/case-insensitive-query-for-a-user-filter/8793/3 "2019-08-08T18:34:27Z")

</div>

Just in case anyone wants to do it the unrecommended quick way. I supplied the regex before passing to the query. This is part of a filtering query that looks through users. If you are looking for "Nick" it would allow for "ic", "NICK", "nick"

In frontend before passed

```auto
textInput = `(?i).*${textInput}.*`;

```

In cypher query

```auto
AND name =~ $textInput

```
