# How to do case insensitive search on terms?

**URL:** <https://discuss.elastic.co/t/how-to-do-case-insensitive-search-on-terms/19790>\
**Category:** Elasticsearch\
**Created:** [September 15, 2014, 3:44pm UTC](https://discuss.elastic.co/t/how-to-do-case-insensitive-search-on-terms/19790 "2014-09-15T15:44:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![javadevmtl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javadevmtl/32/45613_2.png) [@javadevmtl](https://discuss.elastic.co/u/javadevmtl)\
**Post date:** [September 15, 2014, 3:44pm UTC](https://discuss.elastic.co/t/how-to-do-case-insensitive-search-on-terms/19790/1 "2014-09-15T15:44:54Z")

</div>

Using ES 1.3.2

The current application I'm building only uses term queries for exact  
matches.

Example query

"query": {  
"term": {  
"logType": "abc"  
}

The field logType is pulled from external DB as all caps so for instance ABC

If i send the query

"query": {  
"term": {  
"logType": "ABC"  
}

I get no results.

If I send the query

"query": {  
"term": {  
"logType": "abc"  
}

I get results.

So does this mean I need to toLower the input before building the query or  
there's an ES way of doing this?

Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [September 15, 2014, 3:47pm UTC](https://discuss.elastic.co/t/how-to-do-case-insensitive-search-on-terms/19790/2 "2014-09-15T15:47:33Z")

</div>

I assume you use the standard analyzer which uses by default a token filter  
"lowercase".

Just use a custom analyzer, without "lowercase" token filter, and you will  
get case-sensitive search.

Jörg

On Mon, Sep 15, 2014 at 5:44 PM, John Smith [java.dev.mtl@gmail.com](mailto:java.dev.mtl@gmail.com) wrote:

> Using ES 1.3.2
> 
> The current application I'm building only uses term queries for exact  
> matches.
> 
> Example query
> 
> "query": {  
> "term": {  
> "logType": "abc"  
> }
> 
> The field logType is pulled from external DB as all caps so for instance  
> ABC
> 
> If i send the query
> 
> "query": {  
> "term": {  
> "logType": "ABC"  
> }
> 
> I get no results.
> 
> If I send the query
> 
> "query": {  
> "term": {  
> "logType": "abc"  
> }
> 
> I get results.
> 
> So does this mean I need to toLower the input before building the query or  
> there's an ES way of doing this?
> 
> Thanks
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0o8guNsGBaCw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0o8guNsGBaCw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [September 15, 2014, 3:49pm UTC](https://discuss.elastic.co/t/how-to-do-case-insensitive-search-on-terms/19790/3 "2014-09-15T15:49:00Z")

</div>

Or if you want case insensitive search use a match query  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-match-query.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-match-query.html)  
.

On Mon, Sep 15, 2014 at 11:47 AM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
[joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:

> I assume you use the standard analyzer which uses by default a token  
> filter "lowercase".
> 
> Just use a custom analyzer, without "lowercase" token filter, and you will  
> get case-sensitive search.
> 
> Jörg
> 
> On Mon, Sep 15, 2014 at 5:44 PM, John Smith [java.dev.mtl@gmail.com](mailto:java.dev.mtl@gmail.com)  
> wrote:
> 
> > Using ES 1.3.2
> > 
> > The current application I'm building only uses term queries for exact  
> > matches.
> > 
> > Example query
> > 
> > "query": {  
> > "term": {  
> > "logType": "abc"  
> > }
> > 
> > The field logType is pulled from external DB as all caps so for instance  
> > ABC
> > 
> > If i send the query
> > 
> > "query": {  
> > "term": {  
> > "logType": "ABC"  
> > }
> > 
> > I get no results.
> > 
> > If I send the query
> > 
> > "query": {  
> > "term": {  
> > "logType": "abc"  
> > }
> > 
> > I get results.
> > 
> > So does this mean I need to toLower the input before building the query  
> > or there's an ES way of doing this?
> > 
> > Thanks
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0o8guNsGBaCw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0o8guNsGBaCw%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0o8guNsGBaCw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0o8guNsGBaCw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd3q6SNUP6gBDADV802JGSZyO0M6%2BDKP%2BBvBNRwaEr8p0A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd3q6SNUP6gBDADV802JGSZyO0M6%2BDKP%2BBvBNRwaEr8p0A%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [September 15, 2014, 3:49pm UTC](https://discuss.elastic.co/t/how-to-do-case-insensitive-search-on-terms/19790/4 "2014-09-15T15:49:21Z")

</div>

Ugh. Read my post exactly the other way round.

=\> standard analyzer is _not_ using token filter "lowercase"

=\> you can build a custom analyzer _with_ token filter 'lowercase" for  
_case-insensitive_ search.

Jörg

On Mon, Sep 15, 2014 at 5:47 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
[joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:

> I assume you use the standard analyzer which uses by default a token  
> filter "lowercase".
> 
> Just use a custom analyzer, without "lowercase" token filter, and you will  
> get case-sensitive search.
> 
> Jörg
> 
> On Mon, Sep 15, 2014 at 5:44 PM, John Smith [java.dev.mtl@gmail.com](mailto:java.dev.mtl@gmail.com)  
> wrote:
> 
> > Using ES 1.3.2
> > 
> > The current application I'm building only uses term queries for exact  
> > matches.
> > 
> > Example query
> > 
> > "query": {  
> > "term": {  
> > "logType": "abc"  
> > }
> > 
> > The field logType is pulled from external DB as all caps so for instance  
> > ABC
> > 
> > If i send the query
> > 
> > "query": {  
> > "term": {  
> > "logType": "ABC"  
> > }
> > 
> > I get no results.
> > 
> > If I send the query
> > 
> > "query": {  
> > "term": {  
> > "logType": "abc"  
> > }
> > 
> > I get results.
> > 
> > So does this mean I need to toLower the input before building the query  
> > or there's an ES way of doing this?
> > 
> > Thanks
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEHpcSbsbC3S%3DMd9KeCZP0ikhPtCBZu-fVJ8NZod33THg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEHpcSbsbC3S%3DMd9KeCZP0ikhPtCBZu-fVJ8NZod33THg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![javadevmtl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javadevmtl/32/45613_2.png) [@javadevmtl](https://discuss.elastic.co/u/javadevmtl)\
**Post date:** [September 15, 2014, 4:04pm UTC](https://discuss.elastic.co/t/how-to-do-case-insensitive-search-on-terms/19790/5 "2014-09-15T16:04:53Z")

</div>

Thanks!

Yes I want case insensitive search and yes I'm using default analyzer.

Just as you guys answered I tried this...

{  
"query": {  
"query\_string": {  
"fields": ["logType"],  
"query": "ABC"  
}  
}  
}

and it worked. Since I'm searching for "exact" matches (not wildards or  
anything like that) does it make a difference in performance? So far it  
seems like no at least when testing through Sense on the same amount of  
data.

On Monday, 15 September 2014 11:49:33 UTC-4, Nikolas Everett wrote:

> Or if you want case insensitive search use a match query  
> [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-match-query.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-match-query.html)  
> .
> 
> On Mon, Sep 15, 2014 at 11:47 AM, [joerg...@gmail.com](mailto:joerg...@gmail.com) \<javascript:\> \<  
> [joerg...@gmail.com](mailto:joerg...@gmail.com) \<javascript:\>\> wrote:
> 
> > I assume you use the standard analyzer which uses by default a token  
> > filter "lowercase".
> > 
> > Just use a custom analyzer, without "lowercase" token filter, and you  
> > will get case-sensitive search.
> > 
> > Jörg
> > 
> > On Mon, Sep 15, 2014 at 5:44 PM, John Smith \<[java.d...@gmail.com](mailto:java.d...@gmail.com)  
> > \<javascript:\>\> wrote:
> > 
> > > Using ES 1.3.2
> > > 
> > > The current application I'm building only uses term queries for exact  
> > > matches.
> > > 
> > > Example query
> > > 
> > > "query": {  
> > > "term": {  
> > > "logType": "abc"  
> > > }
> > > 
> > > The field logType is pulled from external DB as all caps so for instance  
> > > ABC
> > > 
> > > If i send the query
> > > 
> > > "query": {  
> > > "term": {  
> > > "logType": "ABC"  
> > > }
> > > 
> > > I get no results.
> > > 
> > > If I send the query
> > > 
> > > "query": {  
> > > "term": {  
> > > "logType": "abc"  
> > > }
> > > 
> > > I get results.
> > > 
> > > So does this mean I need to toLower the input before building the query  
> > > or there's an ES way of doing this?
> > > 
> > > Thanks
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0o8guNsGBaCw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0o8guNsGBaCw%40mail.gmail.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0o8guNsGBaCw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0o8guNsGBaCw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b72784e7-48c1-4c10-ab69-77df2c1b6d42%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b72784e7-48c1-4c10-ab69-77df2c1b6d42%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [September 15, 2014, 4:09pm UTC](https://discuss.elastic.co/t/how-to-do-case-insensitive-search-on-terms/19790/6 "2014-09-15T16:09:14Z")

</div>

Use a match instead of a query\_string - query\_string has funky syntax that  
can activate fuzzy matching and search on other fields and stuff - probably  
not what you want. Otherwise it shouldn't have any real impact on  
performance.

On Mon, Sep 15, 2014 at 12:04 PM, John Smith [java.dev.mtl@gmail.com](mailto:java.dev.mtl@gmail.com) wrote:

> Thanks!
> 
> Yes I want case insensitive search and yes I'm using default analyzer.
> 
> Just as you guys answered I tried this...
> 
> {  
> "query": {  
> "query\_string": {  
> "fields": ["logType"],  
> "query": "ABC"  
> }  
> }  
> }
> 
> and it worked. Since I'm searching for "exact" matches (not wildards or  
> anything like that) does it make a difference in performance? So far it  
> seems like no at least when testing through Sense on the same amount of  
> data.
> 
> On Monday, 15 September 2014 11:49:33 UTC-4, Nikolas Everett wrote:
> 
> > Or if you want case insensitive search use a match query  
> > [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-match-query.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-match-query.html)  
> > .
> > 
> > On Mon, Sep 15, 2014 at 11:47 AM, [joerg...@gmail.com](mailto:joerg...@gmail.com) [joerg...@gmail.com](mailto:joerg...@gmail.com)  
> > wrote:
> > 
> > > I assume you use the standard analyzer which uses by default a token  
> > > filter "lowercase".
> > > 
> > > Just use a custom analyzer, without "lowercase" token filter, and you  
> > > will get case-sensitive search.
> > > 
> > > Jörg
> > > 
> > > On Mon, Sep 15, 2014 at 5:44 PM, John Smith [java.d...@gmail.com](mailto:java.d...@gmail.com) wrote:
> > > 
> > > > Using ES 1.3.2
> > > > 
> > > > The current application I'm building only uses term queries for exact  
> > > > matches.
> > > > 
> > > > Example query
> > > > 
> > > > "query": {  
> > > > "term": {  
> > > > "logType": "abc"  
> > > > }
> > > > 
> > > > The field logType is pulled from external DB as all caps so for  
> > > > instance ABC
> > > > 
> > > > If i send the query
> > > > 
> > > > "query": {  
> > > > "term": {  
> > > > "logType": "ABC"  
> > > > }
> > > > 
> > > > I get no results.
> > > > 
> > > > If I send the query
> > > > 
> > > > "query": {  
> > > > "term": {  
> > > > "logType": "abc"  
> > > > }
> > > > 
> > > > I get results.
> > > > 
> > > > So does this mean I need to toLower the input before building the query  
> > > > or there's an ES way of doing this?
> > > > 
> > > > Thanks
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%  
> > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .  
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0  
> > > o8guNsGBaCw%[40mail.gmail.com](http://40mail.gmail.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0o8guNsGBaCw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0o8guNsGBaCw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > .
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/b72784e7-48c1-4c10-ab69-77df2c1b6d42%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b72784e7-48c1-4c10-ab69-77df2c1b6d42%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/b72784e7-48c1-4c10-ab69-77df2c1b6d42%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b72784e7-48c1-4c10-ab69-77df2c1b6d42%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd0Bqco40M1102FXXY8DpyV9Yen0OwaXdE1wHND%3DsaKPNw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd0Bqco40M1102FXXY8DpyV9Yen0OwaXdE1wHND%3DsaKPNw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![javadevmtl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javadevmtl/32/45613_2.png) [@javadevmtl](https://discuss.elastic.co/u/javadevmtl)\
**Post date:** [September 15, 2014, 4:14pm UTC](https://discuss.elastic.co/t/how-to-do-case-insensitive-search-on-terms/19790/7 "2014-09-15T16:14:20Z")

</div>

Thanks match works also.

On Monday, 15 September 2014 12:09:43 UTC-4, Nikolas Everett wrote:

> Use a match instead of a query\_string - query\_string has funky syntax that  
> can activate fuzzy matching and search on other fields and stuff - probably  
> not what you want. Otherwise it shouldn't have any real impact on  
> performance.
> 
> On Mon, Sep 15, 2014 at 12:04 PM, John Smith \<[java.d...@gmail.com](mailto:java.d...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > Thanks!
> > 
> > Yes I want case insensitive search and yes I'm using default analyzer.
> > 
> > Just as you guys answered I tried this...
> > 
> > {  
> > "query": {  
> > "query\_string": {  
> > "fields": ["logType"],  
> > "query": "ABC"  
> > }  
> > }  
> > }
> > 
> > and it worked. Since I'm searching for "exact" matches (not wildards or  
> > anything like that) does it make a difference in performance? So far it  
> > seems like no at least when testing through Sense on the same amount of  
> > data.
> > 
> > On Monday, 15 September 2014 11:49:33 UTC-4, Nikolas Everett wrote:
> > 
> > > Or if you want case insensitive search use a match query  
> > > [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-match-query.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-match-query.html)  
> > > .
> > > 
> > > On Mon, Sep 15, 2014 at 11:47 AM, [joerg...@gmail.com](mailto:joerg...@gmail.com) \<[joerg...@gmail.com](mailto:joerg...@gmail.com)
> > > 
> > > > wrote:
> > > 
> > > > I assume you use the standard analyzer which uses by default a token  
> > > > filter "lowercase".
> > > > 
> > > > Just use a custom analyzer, without "lowercase" token filter, and you  
> > > > will get case-sensitive search.
> > > > 
> > > > Jörg
> > > > 
> > > > On Mon, Sep 15, 2014 at 5:44 PM, John Smith [java.d...@gmail.com](mailto:java.d...@gmail.com)  
> > > > wrote:
> > > > 
> > > > > Using ES 1.3.2
> > > > > 
> > > > > The current application I'm building only uses term queries for exact  
> > > > > matches.
> > > > > 
> > > > > Example query
> > > > > 
> > > > > "query": {  
> > > > > "term": {  
> > > > > "logType": "abc"  
> > > > > }
> > > > > 
> > > > > The field logType is pulled from external DB as all caps so for  
> > > > > instance ABC
> > > > > 
> > > > > If i send the query
> > > > > 
> > > > > "query": {  
> > > > > "term": {  
> > > > > "logType": "ABC"  
> > > > > }
> > > > > 
> > > > > I get no results.
> > > > > 
> > > > > If I send the query
> > > > > 
> > > > > "query": {  
> > > > > "term": {  
> > > > > "logType": "abc"  
> > > > > }
> > > > > 
> > > > > I get results.
> > > > > 
> > > > > So does this mean I need to toLower the input before building the  
> > > > > query or there's an ES way of doing this?
> > > > > 
> > > > > Thanks
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to the Google  
> > > > > Groups "elasticsearch" group.  
> > > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%  
> > > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/8fec1f56-1a59-4d17-bb01-f2ecd62bfbb4%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > .  
> > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0  
> > > > o8guNsGBaCw%[40mail.gmail.com](http://40mail.gmail.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0o8guNsGBaCw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHi-483Tgf5DmwXEfKrGRye1vjvGU4jFL0o8guNsGBaCw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > > .
> > > > 
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google Groups  
> > > "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send an  
> > > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/b72784e7-48c1-4c10-ab69-77df2c1b6d42%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b72784e7-48c1-4c10-ab69-77df2c1b6d42%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/b72784e7-48c1-4c10-ab69-77df2c1b6d42%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b72784e7-48c1-4c10-ab69-77df2c1b6d42%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/07bb0325-ee98-4fe9-a2f1-a88a50a555f8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/07bb0325-ee98-4fe9-a2f1-a88a50a555f8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![harpreet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harpreet/32/3413_2.png) [@harpreet](https://discuss.elastic.co/u/harpreet)\
**Post date:** [July 1, 2015, 3:07pm UTC](https://discuss.elastic.co/t/how-to-do-case-insensitive-search-on-terms/19790/8 "2015-07-01T15:07:39Z")

</div>

I have problem with something similar.

```php
$tjson = '{
                        "query": {
                            "bool": {
                                "should": [
                                    {
                                        "match" : { "keywords": "'.$keywords.'" }
                                    },
                                    {
                                        "match" : { "treatment_name": "'.$keywords.'" }
                                    },
                                    {
                                        "wildcard": {"keywords": "'.$keywords.'*"}
                                    },
                                    {
                                        "wildcard": {"treatment_name": "'.$keywords.'*"}
                                    },
                                    {
                                        "fuzzy": {"keywords": "'.$keywords.'"}
                                    },
                                    {
                                        "fuzzy": {"treatment_name": "'.$keywords.'"}
                                    }
                                ],
                                "must":[
                                    {
                                        "match":{"treatment_status":"active"}
                                    }
                                ],
                                "minimum_should_match": 2
                            }
                        }
                    }';
        $treats['body'] = $tjson;
        $results = $app->client->search($treats);

```

`http://example.com/api/search/heart` return 8 results  
`http://example.com/api/search/HEART` returns only 2 results  
mapping is as following.

```php
$indexParams['body']['settings']['analysis']['analyzer'] = array(
                                                                                              "analyzer_keyword" => array(
                                                                                                                    'tokenizer' => 'standard',
                                                                                                                    "filter"=>"lowercase"
                                                                                                                    )
                                                                                              );

```

```json
...
"keywords": {
            "type": "string",
            "analyzer":"analyzer_keyword"
},"treatment_name": {
            "type": "string",
            "analyzer":"analyzer_keyword"},
...

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:04am UTC](https://discuss.elastic.co/t/how-to-do-case-insensitive-search-on-terms/19790/9 "2017-07-06T00:04:11Z")

</div>


