# Case Insensitive Term Filters

**URL:** <https://discuss.elastic.co/t/case-insensitive-term-filters/12181>\
**Category:** Elasticsearch\
**Created:** [May 30, 2013, 2:36am UTC](https://discuss.elastic.co/t/case-insensitive-term-filters/12181 "2013-05-30T02:36:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbrianjones](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tbrianjones/32/1402_2.png) [@tbrianjones](https://discuss.elastic.co/u/tbrianjones)\
**Post date:** [May 30, 2013, 2:36am UTC](https://discuss.elastic.co/t/case-insensitive-term-filters/12181/1 "2013-05-30T02:36:32Z")

</div>

I have created an analyzer that should simply lowercase a field. I do this  
because I want to be able to filter on full phrases in this field ( eg,  
north dakota ).

My problem is that when I perform a filter against this field, the search  
phrase must now be lowercased. ( eg. "north dakota" works, but "North  
Dakota" does not ).

Must I lowercase the filter phrase on my application end, or is there a way  
to have Elasticsearch do it when a search is performed?

_INDEX_  
{  
"index" : {  
"number\_of\_shards" : 5,  
"number\_of\_replicas" : 1,  
"analysis" : {  
"analyzer" : {  
"string\_lowercase" : {  
"tokenizer" : "keyword",  
"filter" : "lowercase"  
}  
}  
}  
}  
}

_MAPPING_  
{  
"company" : {  
"properties" : {  
"locations" : {  
"type" : "nested",  
"include\_in\_root" : true,  
"properties" : {  
"state" : {  
"type" : "string",  
"index" : "analyzed",  
"analyzer" : "string\_lowercase",  
"include\_in\_all" : true  
}  
}  
}  
}  
}  
}

_QUERY_  
{  
"query": {  
"filtered": {  
"filter": {  
"term": {  
"locations.city": "Port washington"  
}  
},  
"query": {  
"match\_all": []  
}  
}  
}  
}

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 30, 2013, 5:24am UTC](https://discuss.elastic.co/t/case-insensitive-term-filters/12181/2 "2013-05-30T05:24:41Z")

</div>

If you need Elasticsearch to analyze your query, use a MatchQuery wrapped in a QueryFilter.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 30 mai 2013 à 04:36, Brian Jones [tbrianjones@gmail.com](mailto:tbrianjones@gmail.com) a écrit :

I have created an analyzer that should simply lowercase a field. I do this because I want to be able to filter on full phrases in this field ( eg, north dakota ).

My problem is that when I perform a filter against this field, the search phrase must now be lowercased. ( eg. "north dakota" works, but "North Dakota" does not ).

Must I lowercase the filter phrase on my application end, or is there a way to have Elasticsearch do it when a search is performed?

INDEX  
{  
"index" : {  
"number\_of\_shards" : 5,  
"number\_of\_replicas" : 1,  
"analysis" : {  
"analyzer" : {  
"string\_lowercase" : {  
"tokenizer" : "keyword",  
"filter" : "lowercase"  
}  
}  
}  
}  
}

MAPPING  
{  
"company" : {  
"properties" : {  
"locations" : {  
"type" : "nested",  
"include\_in\_root" : true,  
"properties" : {  
"state" : {  
"type" : "string",  
"index" : "analyzed",  
"analyzer" : "string\_lowercase",  
"include\_in\_all" : true  
}  
}  
}  
}  
}  
}

QUERY  
{  
"query": {  
"filtered": {  
"filter": {  
"term": {  
"locations.city": "Port washington"  
}  
},  
"query": {  
"match\_all": []  
}  
}  
}  
}

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:33am UTC](https://discuss.elastic.co/t/case-insensitive-term-filters/12181/3 "2017-07-06T02:33:59Z")

</div>


