# Term Query Not Matching Certain Words

**URL:** <https://discuss.elastic.co/t/term-query-not-matching-certain-words/13999>\
**Category:** Elasticsearch\
**Created:** [October 17, 2013, 6:40pm UTC](https://discuss.elastic.co/t/term-query-not-matching-certain-words/13999 "2013-10-17T18:40:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nariman\_Haghighi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nariman_haghighi/32/1065_2.png) [@Nariman\_Haghighi](https://discuss.elastic.co/u/Nariman_Haghighi)\
**Post date:** [October 17, 2013, 6:40pm UTC](https://discuss.elastic.co/t/term-query-not-matching-certain-words/13999/1 "2013-10-17T18:40:48Z")

</div>

Not able to make any sense of this:

{"from":0,"size":20,"sort":{"created\_time":"desc"},"query":{"term":{"tags":{"value":"permissions"}}}}

Returns as expected:

{"took":0,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max\_score":null,"hits":[{"\_index":"blog","\_type":"BlogPost","\_id":"4a7a21b1-c20f-4131-9938-6306319f3102","\_score":null,  
"\_source" : {  
"year": 2013,  
"month": 10,  
"day": 17,  
"created\_time": 1382026481,  
"id": "4a7a21b1-c20f-4131-9938-6306319f3102",  
"tags": [  
"permissions",  
"UGC",  
"photographer"  
]  
},"sort":[1382026481]}]}}

And:  
{"from":0,"size":20,"sort":{"created\_time":"desc"},"query":{"term":{"tags":{"value":"photographer"}}}}

returns as expected... but  
{"from":0,"size":20,"sort":{"created\_time":"desc"},"query":{"term":{"tags":{"value":"UGC"}}}}  
returns nothing.

Tags is mapped simply as "tags":{"type":"string"}.

--  
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:** [October 17, 2013, 6:47pm UTC](https://discuss.elastic.co/t/term-query-not-matching-certain-words/13999/2 "2013-10-17T18:47:42Z")

</div>

Try with ugc (lower case).

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 17 oct. 2013 à 20:40, Nariman Haghighi [auspicious@gmail.com](mailto:auspicious@gmail.com) a écrit :

> Not able to make any sense of this:
> 
> {"from":0,"size":20,"sort":{"created\_time":"desc"},"query":{"term":{"tags":{"value":"permissions"}}}}
> 
> Returns as expected:
> 
> {"took":0,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max\_score":null,"hits":[{"\_index":"blog","\_type":"BlogPost","\_id":"4a7a21b1-c20f-4131-9938-6306319f3102","\_score":null, "\_source" : {  
> "year": 2013,  
> "month": 10,  
> "day": 17,  
> "created\_time": 1382026481,  
> "id": "4a7a21b1-c20f-4131-9938-6306319f3102",  
> "tags": [  
> "permissions",  
> "UGC",  
> "photographer"  
> ]  
> },"sort":[1382026481]}]}}
> 
> And:  
> {"from":0,"size":20,"sort":{"created\_time":"desc"},"query":{"term":{"tags":{"value":"photographer"}}}}
> 
> returns as expected... but {"from":0,"size":20,"sort":{"created\_time":"desc"},"query":{"term":{"tags":{"value":"UGC"}}}} returns nothing.
> 
> Tags is mapped simply as "tags":{"type":"string"}.
> 
> --  
> 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:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [October 17, 2013, 7:02pm UTC](https://discuss.elastic.co/t/term-query-not-matching-certain-words/13999/3 "2013-10-17T19:02:51Z")

</div>

Just so you know, the reason you need to lowercase ugc yourself is because  
a term query is not analyzed. If you were to use a match query which is  
analyzed, your query should work:

{"from":0,"size":20,"sort":{"created\_time":"desc"},"query":{"match":{"tags":  
"UGC"}}}

Thanks,  
Matt Weber

On Thu, Oct 17, 2013 at 11:47 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Try with ugc (lower case).
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)  
> | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 17 oct. 2013 à 20:40, Nariman Haghighi [auspicious@gmail.com](mailto:auspicious@gmail.com) a écrit :
> 
> Not able to make any sense of this:
> 
> {"from":0,"size":20,"sort":{"created\_time":"desc"},"query":{"term":{"tags":{"value":"permissions"}}}}
> 
> Returns as expected:
> 
> {"took":0,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max\_score":null,"hits":[{"\_index":"blog","\_type":"BlogPost","\_id":"4a7a21b1-c20f-4131-9938-6306319f3102","\_score":null,  
> "\_source" : {  
> "year": 2013,  
> "month": 10,  
> "day": 17,  
> "created\_time": 1382026481,  
> "id": "4a7a21b1-c20f-4131-9938-6306319f3102",  
> "tags": [  
> "permissions",  
> "UGC",  
> "photographer"  
> ]  
> },"sort":[1382026481]}]}}
> 
> And:
> 
> {"from":0,"size":20,"sort":{"created\_time":"desc"},"query":{"term":{"tags":{"value":"photographer"}}}}
> 
> returns as expected... but  
> {"from":0,"size":20,"sort":{"created\_time":"desc"},"query":{"term":{"tags":{"value":"UGC"}}}}  
> returns nothing.
> 
> Tags is mapped simply as "tags":{"type":"string"}.
> 
> --  
> 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).

--  
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:11am UTC](https://discuss.elastic.co/t/term-query-not-matching-certain-words/13999/4 "2017-07-06T02:11:51Z")

</div>


