# Strange behaviour term filter query

**URL:** <https://discuss.elastic.co/t/strange-behaviour-term-filter-query/13507>\
**Category:** Elasticsearch\
**Created:** [September 8, 2013, 10:52am UTC](https://discuss.elastic.co/t/strange-behaviour-term-filter-query/13507 "2013-09-08T10:52:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohit\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@mohit\_Kumar](https://discuss.elastic.co/u/mohit_Kumar)\
**Post date:** [September 8, 2013, 10:52am UTC](https://discuss.elastic.co/t/strange-behaviour-term-filter-query/13507/1 "2013-09-08T10:52:32Z")

</div>

hello folks,  
I have a field name "AuthorLocationCountryCode" which contains the  
abbrevation of the country code. Like United Kingdom = UK, India = IN ,  
United State of America = US.  
I am able to retrive data from elasticsearch with term filter query on US  
and UK.  
Below is the following query.  
ELasticSearch Query :-  
curl -XGET  
'[http://localhost:9200/new\_index/new\_indext/\_search?pretty=false&size=2](http://localhost:9200/new_index/new_indext/_search?pretty=false&size=2)'  
-d'{  
"query": {  
"match\_all": {}  
},  
"filter": {  
"term": {  
"AuthorLocationCountryCode": "_us_"  
}  
},  
"fields": [  
"AuthorLocationCountryCode"  
]  
}'  
OUTPUT :-  
{"took":27,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2197,"max\_score":1.0,"hits":[{"\_index":"new\_index","\_type":"new\_indext","\_id":"317576659379314689","\_score":1.0,"fields":{"AuthorLocationCountryCode":"US  
"}},{"\_index":"new\_index","\_type":"new\_indext","\_id":"317576773602770944","\_score":1.0,"fields":{"AuthorLocationCountryCode":"US  
"}}]}}

_But the query return nothing for INDIA = IN, though we have 120 records_.  
Elasticsearch Query For INDIA = IN  
\*curl -XGET  
'[http://localhost:9200/new\_index/new\_indext/\_search?pretty=false&size=2](http://localhost:9200/new_index/new_indext/_search?pretty=false&size=2)'  
-d'{  
"query": {  
"match\_all": {}  
},  
"filter": {  
"term": {  
"AuthorLocationCountryCode": "in"  
}  
},  
"fields": [  
"AuthorLocationCountryCode"  
]  
}'  
OUTPUT :-  
{"took":6,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max\_score":null,"hits":[]}}  
\*

Will you please guide why this strange behaviour is occuring.  
thanks in advance

regrds  
Mohit

--  
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:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [September 8, 2013, 5:52pm UTC](https://discuss.elastic.co/t/strange-behaviour-term-filter-query/13507/2 "2013-09-08T17:52:57Z")

</div>

any chance that you are using the standard analyzer and "IN" is treated as  
a stopword and filtered away?

simon

On Sunday, September 8, 2013 12:52:32 PM UTC+2, Mohit Kumar Yadav wrote:

> hello folks,  
> I have a field name "AuthorLocationCountryCode" which contains the  
> abbrevation of the country code. Like United Kingdom = UK, India = IN ,  
> United State of America = US.  
> I am able to retrive data from elasticsearch with term filter query on US  
> and UK.  
> Below is the following query.  
> ELasticSearch Query :-  
> curl -XGET '  
> [http://localhost:9200/new\_index/new\_indext/\_search?pretty=false&size=2](http://localhost:9200/new_index/new_indext/_search?pretty=false&size=2)'  
> -d'{  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "term": {  
> "AuthorLocationCountryCode": "_us_"  
> }  
> },  
> "fields": [  
> "AuthorLocationCountryCode"  
> ]  
> }'  
> OUTPUT :-  
> {"took":27,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2197,"max\_score":1.0,"hits":[{"\_index":"new\_index","\_type":"new\_indext","\_id":"317576659379314689","\_score":1.0,"fields":{"AuthorLocationCountryCode":"US  
> "}},{"\_index":"new\_index","\_type":"new\_indext","\_id":"317576773602770944","\_score":1.0,"fields":{"AuthorLocationCountryCode":"US  
> "}}]}}
> 
> _But the query return nothing for INDIA = IN, though we have 120 records_.  
> Elasticsearch Query For INDIA = IN  
> \*curl -XGET '  
> [http://localhost:9200/new\_index/new\_indext/\_search?pretty=false&size=2](http://localhost:9200/new_index/new_indext/_search?pretty=false&size=2)'  
> -d'{  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "term": {  
> "AuthorLocationCountryCode": "in"  
> }  
> },  
> "fields": [  
> "AuthorLocationCountryCode"  
> ]  
> }'  
> OUTPUT :-
> 
> {"took":6,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max\_score":null,"hits":}}  
> \*
> 
> Will you please guide why this strange behaviour is occuring.  
> thanks in advance
> 
> regrds  
> Mohit

--  
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:** ![mohit\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@mohit\_Kumar](https://discuss.elastic.co/u/mohit_Kumar)\
**Post date:** [September 9, 2013, 12:07pm UTC](https://discuss.elastic.co/t/strange-behaviour-term-filter-query/13507/3 "2013-09-09T12:07:47Z")

</div>

hi simon,

I just download the elasticsearch, set the mapping and put some values and  
start using it I have not set any analyzer. Here is my mapping query:  
curl -XPUT '[http://localhost:9200/new\_index/new\_indext/\_mapping](http://localhost:9200/new_index/new_indext/_mapping)'  
-d'{"new\_indext":{"properties":{"Message":{"type":"string"},"Name":{"type":"string"},"AuthorLocationCountryCode":{"type":"string"}}}}'

Is Elasticsearch has its default standard analyzer to filter stopword?  
To use the analyzer I have to edit in my current mapping or I have to setup  
another mapping.?  
thank you for reply and yours precious time and advice.

On Sunday, September 8, 2013 11:22:57 PM UTC+5:30, simonw wrote:

> any chance that you are using the standard analyzer and "IN" is treated as  
> a stopword and filtered away?
> 
> simon
> 
> On Sunday, September 8, 2013 12:52:32 PM UTC+2, Mohit Kumar Yadav wrote:
> 
> > hello folks,  
> > I have a field name "AuthorLocationCountryCode" which contains the  
> > abbrevation of the country code. Like United Kingdom = UK, India = IN ,  
> > United State of America = US.  
> > I am able to retrive data from elasticsearch with term filter query on US  
> > and UK.  
> > Below is the following query.  
> > ELasticSearch Query :-  
> > curl -XGET '  
> > [http://localhost:9200/new\_index/new\_indext/\_search?pretty=false&size=2](http://localhost:9200/new_index/new_indext/_search?pretty=false&size=2)'  
> > -d'{  
> > "query": {  
> > "match\_all": {}  
> > },  
> > "filter": {  
> > "term": {  
> > "AuthorLocationCountryCode": "_us_"  
> > }  
> > },  
> > "fields": [  
> > "AuthorLocationCountryCode"  
> > ]  
> > }'  
> > OUTPUT :-  
> > {"took":27,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2197,"max\_score":1.0,"hits":[{"\_index":"new\_index","\_type":"new\_indext","\_id":"317576659379314689","\_score":1.0,"fields":{"AuthorLocationCountryCode":"US  
> > "}},{"\_index":"new\_index","\_type":"new\_indext","\_id":"317576773602770944","\_score":1.0,"fields":{"AuthorLocationCountryCode":"US  
> > "}}]}}
> > 
> > _But the query return nothing for INDIA = IN, though we have 120 records_  
> > .  
> > Elasticsearch Query For INDIA = IN  
> > \*curl -XGET '  
> > [http://localhost:9200/new\_index/new\_indext/\_search?pretty=false&size=2](http://localhost:9200/new_index/new_indext/_search?pretty=false&size=2)'  
> > -d'{  
> > "query": {  
> > "match\_all": {}  
> > },  
> > "filter": {  
> > "term": {  
> > "AuthorLocationCountryCode": "in"  
> > }  
> > },  
> > "fields": [  
> > "AuthorLocationCountryCode"  
> > ]  
> > }'  
> > OUTPUT :-
> > 
> > {"took":6,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max\_score":null,"hits":}}  
> > \*
> > 
> > Will you please guide why this strange behaviour is occuring.  
> > thanks in advance
> > 
> > regrds  
> > Mohit

--  
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:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [September 9, 2013, 4:37pm UTC](https://discuss.elastic.co/t/strange-behaviour-term-filter-query/13507/4 "2013-09-09T16:37:29Z")

</div>

Hi,  
yes english stopwords are applied by default, you need to submit your own  
mapping ither while creating the index or using the put mapping api.

Cheers

On Monday, September 9, 2013 2:07:47 PM UTC+2, Mohit Kumar Yadav wrote:

> hi simon,
> 
> I just download the elasticsearch, set the mapping and put some values and  
> start using it I have not set any analyzer. Here is my mapping query:  
> curl -XPUT '[http://localhost:9200/new\_index/new\_indext/\_mapping](http://localhost:9200/new_index/new_indext/_mapping)'  
> -d'{"new\_indext":{"properties":{"Message":{"type":"string"},"Name":{"type":"string"},"AuthorLocationCountryCode":{"type":"string"}}}}'
> 
> Is Elasticsearch has its default standard analyzer to filter stopword?  
> To use the analyzer I have to edit in my current mapping or I have to  
> setup another mapping.?  
> thank you for reply and yours precious time and advice.
> 
> On Sunday, September 8, 2013 11:22:57 PM UTC+5:30, simonw wrote:
> 
> > any chance that you are using the standard analyzer and "IN" is treated  
> > as a stopword and filtered away?
> > 
> > simon
> > 
> > On Sunday, September 8, 2013 12:52:32 PM UTC+2, Mohit Kumar Yadav wrote:
> > 
> > > hello folks,  
> > > I have a field name "AuthorLocationCountryCode" which contains the  
> > > abbrevation of the country code. Like United Kingdom = UK, India = IN ,  
> > > United State of America = US.  
> > > I am able to retrive data from elasticsearch with term filter query on  
> > > US and UK.  
> > > Below is the following query.  
> > > ELasticSearch Query :-  
> > > curl -XGET '  
> > > [http://localhost:9200/new\_index/new\_indext/\_search?pretty=false&size=2](http://localhost:9200/new_index/new_indext/_search?pretty=false&size=2)'  
> > > -d'{  
> > > "query": {  
> > > "match\_all": {}  
> > > },  
> > > "filter": {  
> > > "term": {  
> > > "AuthorLocationCountryCode": "_us_"  
> > > }  
> > > },  
> > > "fields": [  
> > > "AuthorLocationCountryCode"  
> > > ]  
> > > }'  
> > > OUTPUT :-  
> > > {"took":27,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2197,"max\_score":1.0,"hits":[{"\_index":"new\_index","\_type":"new\_indext","\_id":"317576659379314689","\_score":1.0,"fields":{"AuthorLocationCountryCode":"US  
> > > "}},{"\_index":"new\_index","\_type":"new\_indext","\_id":"317576773602770944","\_score":1.0,"fields":{"AuthorLocationCountryCode":"US  
> > > "}}]}}
> > > 
> > > \*But the query return nothing for INDIA = IN, though we have 120 records  
> > > \*.  
> > > Elasticsearch Query For INDIA = IN  
> > > \*curl -XGET '  
> > > [http://localhost:9200/new\_index/new\_indext/\_search?pretty=false&size=2](http://localhost:9200/new_index/new_indext/_search?pretty=false&size=2)'  
> > > -d'{  
> > > "query": {  
> > > "match\_all": {}  
> > > },  
> > > "filter": {  
> > > "term": {  
> > > "AuthorLocationCountryCode": "in"  
> > > }  
> > > },  
> > > "fields": [  
> > > "AuthorLocationCountryCode"  
> > > ]  
> > > }'  
> > > OUTPUT :-
> > > 
> > > {"took":6,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max\_score":null,"hits":}}  
> > > \*
> > > 
> > > Will you please guide why this strange behaviour is occuring.  
> > > thanks in advance
> > > 
> > > regrds  
> > > Mohit

--  
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:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [September 10, 2013, 4:27am UTC](https://discuss.elastic.co/t/strange-behaviour-term-filter-query/13507/5 "2013-09-10T04:27:25Z")

</div>

yes you need to change your mapping. I'd just use `simple` analyzer for  
this lanugage field which just lowercases basically.

simon

On Monday, September 9, 2013 2:07:47 PM UTC+2, Mohit Kumar Yadav wrote:

> hi simon,
> 
> I just download the elasticsearch, set the mapping and put some values and  
> start using it I have not set any analyzer. Here is my mapping query:  
> curl -XPUT '[http://localhost:9200/new\_index/new\_indext/\_mapping](http://localhost:9200/new_index/new_indext/_mapping)'  
> -d'{"new\_indext":{"properties":{"Message":{"type":"string"},"Name":{"type":"string"},"AuthorLocationCountryCode":{"type":"string"}}}}'
> 
> Is Elasticsearch has its default standard analyzer to filter stopword?  
> To use the analyzer I have to edit in my current mapping or I have to  
> setup another mapping.?  
> thank you for reply and yours precious time and advice.
> 
> On Sunday, September 8, 2013 11:22:57 PM UTC+5:30, simonw wrote:
> 
> > any chance that you are using the standard analyzer and "IN" is treated  
> > as a stopword and filtered away?
> > 
> > simon
> > 
> > On Sunday, September 8, 2013 12:52:32 PM UTC+2, Mohit Kumar Yadav wrote:
> > 
> > > hello folks,  
> > > I have a field name "AuthorLocationCountryCode" which contains the  
> > > abbrevation of the country code. Like United Kingdom = UK, India = IN ,  
> > > United State of America = US.  
> > > I am able to retrive data from elasticsearch with term filter query on  
> > > US and UK.  
> > > Below is the following query.  
> > > ELasticSearch Query :-  
> > > curl -XGET '  
> > > [http://localhost:9200/new\_index/new\_indext/\_search?pretty=false&size=2](http://localhost:9200/new_index/new_indext/_search?pretty=false&size=2)'  
> > > -d'{  
> > > "query": {  
> > > "match\_all": {}  
> > > },  
> > > "filter": {  
> > > "term": {  
> > > "AuthorLocationCountryCode": "_us_"  
> > > }  
> > > },  
> > > "fields": [  
> > > "AuthorLocationCountryCode"  
> > > ]  
> > > }'  
> > > OUTPUT :-  
> > > {"took":27,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2197,"max\_score":1.0,"hits":[{"\_index":"new\_index","\_type":"new\_indext","\_id":"317576659379314689","\_score":1.0,"fields":{"AuthorLocationCountryCode":"US  
> > > "}},{"\_index":"new\_index","\_type":"new\_indext","\_id":"317576773602770944","\_score":1.0,"fields":{"AuthorLocationCountryCode":"US  
> > > "}}]}}
> > > 
> > > \*But the query return nothing for INDIA = IN, though we have 120 records  
> > > \*.  
> > > Elasticsearch Query For INDIA = IN  
> > > \*curl -XGET '  
> > > [http://localhost:9200/new\_index/new\_indext/\_search?pretty=false&size=2](http://localhost:9200/new_index/new_indext/_search?pretty=false&size=2)'  
> > > -d'{  
> > > "query": {  
> > > "match\_all": {}  
> > > },  
> > > "filter": {  
> > > "term": {  
> > > "AuthorLocationCountryCode": "in"  
> > > }  
> > > },  
> > > "fields": [  
> > > "AuthorLocationCountryCode"  
> > > ]  
> > > }'  
> > > OUTPUT :-
> > > 
> > > {"took":6,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max\_score":null,"hits":}}  
> > > \*
> > > 
> > > Will you please guide why this strange behaviour is occuring.  
> > > thanks in advance
> > > 
> > > regrds  
> > > Mohit

--  
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:17am UTC](https://discuss.elastic.co/t/strange-behaviour-term-filter-query/13507/6 "2017-07-06T02:17:23Z")

</div>


