# Term filter not working for select strings?

**URL:** <https://discuss.elastic.co/t/term-filter-not-working-for-select-strings/15089>\
**Category:** Elasticsearch\
**Created:** [January 3, 2014, 4:27am UTC](https://discuss.elastic.co/t/term-filter-not-working-for-select-strings/15089 "2014-01-03T04:27:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kakaner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kakaner/32/1892_2.png) [@kakaner](https://discuss.elastic.co/u/kakaner)\
**Post date:** [January 3, 2014, 4:27am UTC](https://discuss.elastic.co/t/term-filter-not-working-for-select-strings/15089/1 "2014-01-03T04:27:18Z")

</div>

Hi!

I recently discovered select term filters weren't working on my dataset,  
and narrowed it down to an example involving two letter strings.

This is reproducible on 0.90.2/5/7 both locally and on remote hosts with  
the following commands:

curl -XPUT '[http://localhost:9200/index1/type1/1](http://localhost:9200/index1/type1/1)' -d '{"code":"zh",  
"name":"China"}'  
curl -XPUT '[http://localhost:9200/index1/type1/2](http://localhost:9200/index1/type1/2)' -d '{"code":"in",  
"name":"India"}'

curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
'{"query":{"term":{"code":"zh"}}}' // returns Doc 1  
_curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
'{"query":{"term":{"code":"in"}}}' // returns nothing_

curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
'{"query":{"term":{"name":"china"}}}' // returns Doc 1  
curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
'{"query":{"term":{"name":"india"}}}' // returns Doc 2

No mappings or analyzers were used. Is there something obvious I'm missing  
here? Thanks!  
~Karen

--  
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/92cf01a9-9942-4f7e-8fd0-f39e9ed8805b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/92cf01a9-9942-4f7e-8fd0-f39e9ed8805b%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [January 3, 2014, 5:42am UTC](https://discuss.elastic.co/t/term-filter-not-working-for-select-strings/15089/2 "2014-01-03T05:42:52Z")

</div>

The default analyzer uses a stop word filter and "in" is considered a stop  
word. If you are using term queries, then setting your field to  
non\_analyzed will probably be your best fix.

Cheers,

Ivan

On Thu, Jan 2, 2014 at 8:27 PM, kakaner [kakaner@gmail.com](mailto:kakaner@gmail.com) wrote:

> Hi!
> 
> I recently discovered select term filters weren't working on my dataset,  
> and narrowed it down to an example involving two letter strings.
> 
> This is reproducible on 0.90.2/5/7 both locally and on remote hosts with  
> the following commands:
> 
> curl -XPUT '[http://localhost:9200/index1/type1/1](http://localhost:9200/index1/type1/1)' -d '{"code":"zh",  
> "name":"China"}'  
> curl -XPUT '[http://localhost:9200/index1/type1/2](http://localhost:9200/index1/type1/2)' -d '{"code":"in",  
> "name":"India"}'
> 
> curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
> '{"query":{"term":{"code":"zh"}}}' // returns Doc 1  
> _curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)  
> [http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
> '{"query":{"term":{"code":"in"}}}' // returns nothing_
> 
> curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
> '{"query":{"term":{"name":"china"}}}' // returns Doc 1  
> curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
> '{"query":{"term":{"name":"india"}}}' // returns Doc 2
> 
> No mappings or analyzers were used. Is there something obvious I'm missing  
> here? Thanks!  
> ~Karen
> 
> --  
> 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/92cf01a9-9942-4f7e-8fd0-f39e9ed8805b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/92cf01a9-9942-4f7e-8fd0-f39e9ed8805b%40googlegroups.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCxv2KxnwN1A5cwWFYa\_P%3DdRmtLoHTsSi9PjWjVuR%3Dzdw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCxv2KxnwN1A5cwWFYa_P%3DdRmtLoHTsSi9PjWjVuR%3Dzdw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![kakaner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kakaner/32/1892_2.png) [@kakaner](https://discuss.elastic.co/u/kakaner)\
**Post date:** [January 3, 2014, 6:08am UTC](https://discuss.elastic.co/t/term-filter-not-working-for-select-strings/15089/3 "2014-01-03T06:08:40Z")

</div>

Thanks Ivan!! That makes a ton of sense and can't believe I overlooked  
that. Happened to be one of our unmapped fields 🙂

On Friday, January 3, 2014 12:42:52 AM UTC-5, Ivan Brusic wrote:

> The default analyzer uses a stop word filter and "in" is considered a stop  
> word. If you are using term queries, then setting your field to  
> non\_analyzed will probably be your best fix.
> 
> Cheers,
> 
> Ivan
> 
> On Thu, Jan 2, 2014 at 8:27 PM, kakaner \<[kak...@gmail.com](mailto:kak...@gmail.com) \<javascript:\>\>wrote:
> 
> > Hi!
> > 
> > I recently discovered select term filters weren't working on my dataset,  
> > and narrowed it down to an example involving two letter strings.
> > 
> > This is reproducible on 0.90.2/5/7 both locally and on remote hosts with  
> > the following commands:
> > 
> > curl -XPUT '[http://localhost:9200/index1/type1/1](http://localhost:9200/index1/type1/1)' -d '{"code":"zh",  
> > "name":"China"}'  
> > curl -XPUT '[http://localhost:9200/index1/type1/2](http://localhost:9200/index1/type1/2)' -d '{"code":"in",  
> > "name":"India"}'
> > 
> > curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
> > '{"query":{"term":{"code":"zh"}}}' // returns Doc 1  
> > _curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)  
> > [http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
> > '{"query":{"term":{"code":"in"}}}' // returns nothing_
> > 
> > curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
> > '{"query":{"term":{"name":"china"}}}' // returns Doc 1  
> > curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
> > '{"query":{"term":{"name":"india"}}}' // returns Doc 2
> > 
> > No mappings or analyzers were used. Is there something obvious I'm  
> > missing here? Thanks!  
> > ~Karen
> > 
> > --  
> > 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/92cf01a9-9942-4f7e-8fd0-f39e9ed8805b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/92cf01a9-9942-4f7e-8fd0-f39e9ed8805b%40googlegroups.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e7973b97-e891-4918-b76f-60c13817aae9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e7973b97-e891-4918-b76f-60c13817aae9%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [January 3, 2014, 7:00am UTC](https://discuss.elastic.co/t/term-filter-not-working-for-select-strings/15089/4 "2014-01-03T07:00:14Z")

</div>

After all my years of development, I would be surprised if I did NOT make a  
silly mistake!

--  
Ivan

On Thu, Jan 2, 2014 at 10:08 PM, kakaner [kakaner@gmail.com](mailto:kakaner@gmail.com) wrote:

> Thanks Ivan!! That makes a ton of sense and can't believe I overlooked  
> that. Happened to be one of our unmapped fields 🙂
> 
> On Friday, January 3, 2014 12:42:52 AM UTC-5, Ivan Brusic wrote:
> 
> > The default analyzer uses a stop word filter and "in" is considered a  
> > stop word. If you are using term queries, then setting your field to  
> > non\_analyzed will probably be your best fix.
> > 
> > Cheers,
> > 
> > Ivan
> > 
> > On Thu, Jan 2, 2014 at 8:27 PM, kakaner [kak...@gmail.com](mailto:kak...@gmail.com) wrote:
> > 
> > > Hi!
> > > 
> > > I recently discovered select term filters weren't working on my dataset,  
> > > and narrowed it down to an example involving two letter strings.
> > > 
> > > This is reproducible on 0.90.2/5/7 both locally and on remote hosts with  
> > > the following commands:
> > > 
> > > curl -XPUT '[http://localhost:9200/index1/type1/1](http://localhost:9200/index1/type1/1)' -d '{"code":"zh",  
> > > "name":"China"}'  
> > > curl -XPUT '[http://localhost:9200/index1/type1/2](http://localhost:9200/index1/type1/2)' -d '{"code":"in",  
> > > "name":"India"}'
> > > 
> > > curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
> > > '{"query":{"term":{"code":"zh"}}}' // returns Doc 1  
> > > _curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)  
> > > [http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
> > > '{"query":{"term":{"code":"in"}}}' // returns nothing_
> > > 
> > > curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
> > > '{"query":{"term":{"name":"china"}}}' // returns Doc 1  
> > > curl '[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)' -d  
> > > '{"query":{"term":{"name":"india"}}}' // returns Doc 2
> > > 
> > > No mappings or analyzers were used. Is there something obvious I'm  
> > > missing here? Thanks!  
> > > ~Karen
> > > 
> > > --  
> > > 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/92cf01a9-9942-4f7e-8fd0-f39e9ed8805b%  
> > > [40googlegroups.com](http://40googlegroups.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).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/e7973b97-e891-4918-b76f-60c13817aae9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e7973b97-e891-4918-b76f-60c13817aae9%40googlegroups.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQDMoQ9pB%2BCRDTscQWCLmZBh0H71kFFFvEO-Kof0BwDvEg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQDMoQ9pB%2BCRDTscQWCLmZBh0H71kFFFvEO-Kof0BwDvEg%40mail.gmail.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, 1:58am UTC](https://discuss.elastic.co/t/term-filter-not-working-for-select-strings/15089/5 "2017-07-06T01:58:34Z")

</div>


