# Term query case insensitive

**URL:** <https://discuss.elastic.co/t/term-query-case-insensitive/8606>\
**Category:** Elasticsearch\
**Created:** [August 2, 2012, 12:11pm UTC](https://discuss.elastic.co/t/term-query-case-insensitive/8606 "2012-08-02T12:11:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![michalj](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@michalj](https://discuss.elastic.co/u/michalj)\
**Post date:** [August 2, 2012, 12:11pm UTC](https://discuss.elastic.co/t/term-query-case-insensitive/8606/1 "2012-08-02T12:11:51Z")

</div>

Hi.I'm having problems with term queries.I want to search with terms case in-sensitive.I found this post: [http://elasticsearch-users.115913.n3.nabble.com/Mapping-not-analyzed-field-but-making-it-not-case-sensitive-td3537033.html](http://elasticsearch-users.115913.n3.nabble.com/Mapping-not-analyzed-field-but-making-it-not-case-sensitive-td3537033.html), but I don't think it works for me.I'll put an example of my queries:1. Query for analyzed part, document value uppercased{ "query": { "term": { "personal.country": "country" } }}Returns document  
2. Query for not analyzed part, doc value same as term value{ "query": { "term": { "device.brand": "Brand 1" } }}Returns document  
3. Query for not analyzed part, term value starts with lower case{ "query": { "term": { "device.brand": "brand 1" } }}Do not retuns document as I would expect.  
Is it possible to make a term query to not analyzed properties that will ignore case sensitivity?Is it problem with my configuration?  
BR.  
I'm using ES in 0.19.8.My data:{ "device":{ "brand": "Brand 1", "model": "bRAND 2" }, "personal": { "login": "login", "firstName": "first name", "lastName": "last name", "address": "address", "zipCode": "zip code", "city": "city", "country": "COUNTRY", "language": "LanGuage" }}  
My ES config:index: analysis: analyzer: string\_lowercase: tokenizer: keyword filter: lowercaseES Mapping:{"mappings":{ "subscriber": { "properties": { "device":{ "type": "object", "properties": { "brand": { "type": "string", "index" : "not\_analyzed", "analyzer" : "string\_lowercase" }, "model": { "type": "string", "index" : "not\_analyzed", "analyzer" : "string\_lowercase" } } }, "personal": { "type": "object", "properties": { "login": { "type": "string" }, "firstName": { "type": "string" }, "lastName": { "type": "string" }, "address": { "type": "string" }, "zipCode": { "type": "string" }, "city": { "type": "string" }, "country": { "type": "string" }, "language": { "type": "string" } } } } } }}

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [August 2, 2012, 2:31pm UTC](https://discuss.elastic.co/t/term-query-case-insensitive/8606/2 "2012-08-02T14:31:23Z")

</div>

Your fields should now be "analyzed" (using the specified analyzer) and not  
"not\_analyzed".

--  
Ivan  
On Aug 2, 2012 5:11 AM, "misiek jendryszka" [oniron9th@hotmail.com](mailto:oniron9th@hotmail.com) wrote:

> Hi.  
> I'm having problems with term queries.  
> I want to search with terms case in-sensitive.  
> I found this post:  
> [http://elasticsearch-users.115913.n3.nabble.com/Mapping-not-analyzed-field-but-making-it-not-case-sensitive-td3537033.html](http://elasticsearch-users.115913.n3.nabble.com/Mapping-not-analyzed-field-but-making-it-not-case-sensitive-td3537033.html),  
> but I don't think it works for me.  
> I'll put an example of my queries:
> 
> 1. Query for analyzed part, document value uppercased  
> {  
> "query": {  
> "term": {  
> "personal.country": "country"  
> }  
> }  
> }  
> Returns document
> 
> 2. Query for not analyzed part, doc value same as term value  
> {  
> "query": {  
> "term": {  
> "device.brand": "Brand 1"  
> }  
> }  
> }  
> Returns document
> 
> 3. Query for not analyzed part, term value starts with lower case  
> {  
> "query": {  
> "term": {  
> "device.brand": "brand 1"  
> }  
> }  
> }  
> Do not retuns document as I would expect.
> 
> Is it possible to make a term query to not analyzed properties that will  
> ignore case sensitivity?  
> Is it problem with my configuration?
> 
> BR.
> 
> I'm using ES in 0.19.8.  
> My data:  
> {  
> "device":{  
> "brand": "Brand 1",  
> "model": "bRAND 2"  
> },  
> "personal": {  
> "login": "login",  
> "firstName": "first name",  
> "lastName": "last name",  
> "address": "address",  
> "zipCode": "zip code",  
> "city": "city",  
> "country": "COUNTRY",  
> "language": "LanGuage"  
> }  
> }
> 
> My ES config:  
> index:  
> analysis:  
> analyzer:  
> string\_lowercase:  
> tokenizer: keyword  
> filter: lowercase  
> ES Mapping:  
> {"mappings":{  
> "subscriber": {  
> "properties": {  
> "device":{  
> "type": "object",  
> "properties": {  
> "brand": {  
> "type": "string",  
> "index" : "not\_analyzed",  
> "analyzer" : "string\_lowercase"  
> },  
> "model": {  
> "type": "string",  
> "index" : "not\_analyzed",  
> "analyzer" : "string\_lowercase"  
> }  
> }  
> },  
> "personal": {  
> "type": "object",  
> "properties": {  
> "login": {  
> "type": "string"  
> },  
> "firstName": {  
> "type": "string"  
> },  
> "lastName": {  
> "type": "string"  
> },  
> "address": {  
> "type": "string"  
> },  
> "zipCode": {  
> "type": "string"  
> },  
> "city": {  
> "type": "string"  
> },  
> "country": {  
> "type": "string"  
> },  
> "language": {  
> "type": "string"  
> }  
> }  
> }  
> }  
> }  
> }  
> }

---

<div class="post-metadata">

**Author:** ![michalj](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@michalj](https://discuss.elastic.co/u/michalj)\
**Post date:** [August 2, 2012, 2:41pm UTC](https://discuss.elastic.co/t/term-query-case-insensitive/8606/3 "2012-08-02T14:41:46Z")

</div>

I sse Your point  
I can always write custom analyzer for some fields.  
Thanks 🙂

---

<div class="post-metadata">

**Author:** ![Suraj](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@Suraj](https://discuss.elastic.co/u/Suraj)\
**Post date:** [August 20, 2012, 4:42am UTC](https://discuss.elastic.co/t/term-query-case-insensitive/8606/4 "2012-08-20T04:42:55Z")

</div>

Hi michalj,  
Can you please share the custom analyzer for this case.  
Thanks

---

<div class="post-metadata">

**Author:** ![Suraj](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@Suraj](https://discuss.elastic.co/u/Suraj)\
**Post date:** [August 20, 2012, 10:34am UTC](https://discuss.elastic.co/t/term-query-case-insensitive/8606/5 "2012-08-20T10:34:01Z")

</div>

Hi michalj,  
Can you please share the custom analyzer for this case? Its not working as  
I have tried every way to get the facted search with case insensitive.  
Thanks

On Thursday, August 2, 2012 5:56:51 PM UTC+5:45, misiek jendryszka wrote:

> Hi.  
> I'm having problems with term queries.  
> I want to search with terms case in-sensitive.  
> I found this post:  
> [http://elasticsearch-users.115913.n3.nabble.com/Mapping-not-analyzed-field-but-making-it-not-case-sensitive-td3537033.html](http://elasticsearch-users.115913.n3.nabble.com/Mapping-not-analyzed-field-but-making-it-not-case-sensitive-td3537033.html),  
> but I don't think it works for me.  
> I'll put an example of my queries:
> 
> 1. Query for analyzed part, document value uppercased  
> {  
> "query": {  
> "term": {  
> "personal.country": "country"  
> }  
> }  
> }  
> Returns document
> 
> 2. Query for not analyzed part, doc value same as term value  
> {  
> "query": {  
> "term": {  
> "device.brand": "Brand 1"  
> }  
> }  
> }  
> Returns document
> 
> 3. Query for not analyzed part, term value starts with lower case  
> {  
> "query": {  
> "term": {  
> "device.brand": "brand 1"  
> }  
> }  
> }  
> Do not retuns document as I would expect.
> 
> Is it possible to make a term query to not analyzed properties that will  
> ignore case sensitivity?  
> Is it problem with my configuration?
> 
> BR.
> 
> I'm using ES in 0.19.8.  
> My data:  
> {  
> "device":{  
> "brand": "Brand 1",  
> "model": "bRAND 2"  
> },  
> "personal": {  
> "login": "login",  
> "firstName": "first name",  
> "lastName": "last name",  
> "address": "address",  
> "zipCode": "zip code",  
> "city": "city",  
> "country": "COUNTRY",  
> "language": "LanGuage"  
> }  
> }
> 
> My ES config:  
> index:  
> analysis:  
> analyzer:  
> string\_lowercase:  
> tokenizer: keyword  
> filter: lowercase  
> ES Mapping:  
> {"mappings":{  
> "subscriber": {  
> "properties": {  
> "device":{  
> "type": "object",  
> "properties": {  
> "brand": {  
> "type": "string",  
> "index" : "not\_analyzed",  
> "analyzer" : "string\_lowercase"  
> },  
> "model": {  
> "type": "string",  
> "index" : "not\_analyzed",  
> "analyzer" : "string\_lowercase"  
> }  
> }  
> },  
> "personal": {  
> "type": "object",  
> "properties": {  
> "login": {  
> "type": "string"  
> },  
> "firstName": {  
> "type": "string"  
> },  
> "lastName": {  
> "type": "string"  
> },  
> "address": {  
> "type": "string"  
> },  
> "zipCode": {  
> "type": "string"  
> },  
> "city": {  
> "type": "string"  
> },  
> "country": {  
> "type": "string"  
> },  
> "language": {  
> "type": "string"  
> }  
> }  
> }  
> }  
> }  
> }  
> }

--

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [August 24, 2012, 3:50pm UTC](https://discuss.elastic.co/t/term-query-case-insensitive/8606/6 "2012-08-24T15:50:25Z")

</div>

Suraj,

He already did in his original post. It is called string\_lowercase.

--  
Ivan

On Sun, Aug 19, 2012 at 9:42 PM, Suraj [surajyonzon@gmail.com](mailto:surajyonzon@gmail.com) wrote:

> Hi michalj,  
> Can you please share the custom analyzer for this case.  
> Thanks
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Term-query-case-insensitive-tp4021165p4021894.html](http://elasticsearch-users.115913.n3.nabble.com/Term-query-case-insensitive-tp4021165p4021894.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --

--

---

<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, 3:15am UTC](https://discuss.elastic.co/t/term-query-case-insensitive/8606/7 "2017-07-06T03:15:09Z")

</div>


