# Question with terms filter

**URL:** <https://discuss.elastic.co/t/question-with-terms-filter/13380>\
**Category:** Elasticsearch\
**Created:** [August 29, 2013, 1:55am UTC](https://discuss.elastic.co/t/question-with-terms-filter/13380 "2013-08-29T01:55:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rfq](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rfq](https://discuss.elastic.co/u/rfq)\
**Post date:** [August 29, 2013, 1:55am UTC](https://discuss.elastic.co/t/question-with-terms-filter/13380/1 "2013-08-29T01:55:43Z")

</div>

I'm using elasticsearch-0.90.3 and had a question with the terms filter.

I'm storing the id of an author on a comment as such:

curl -XPUT localhost:9200/comments/comment/1 -d '{ "author" :  
"qQabqD5yRjCHUOxPgifKVA"}'

However, when I try to filter by terms using this field, I'm getting  
nothing back:

curl -XGET '[http://localhost:9200/comments/\_search](http://localhost:9200/comments/_search)' -d '{  
"query" : {  
"filtered" {  
"filter" : {  
"terms" : {  
"author" : ["qQabqD5yRjCHUOxPgifKVA"]  
}  
}  
}  
}  
}'

{"took":0,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},  
"hits":{"total":0,"max\_score":null,"hits":[]}}

If instead, I use a word (or name), it works out, though:

curl -XPUT localhost:9200/comments/comment/1 -d '{ "author" : "ruben"}'

curl -XGET '[http://localhost:9200/questions/\_search](http://localhost:9200/questions/_search)' -d '{  
"query" : {  
"filtered" : {  
"filter" : {  
"terms" : {  
"author" : ["ruben"]  
}  
}  
}  
}  
}'

{"took":1,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},  
"hits":{"total":1,"max\_score":1.0,"hits":[{"\_index":"questions","\_type":  
"question","\_id":"1","\_score":1.0, "\_source" : { "author" : "ruben"}}]}}

What am I doing wrong?

Thanks,

- Ruben

--  
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:** [August 29, 2013, 6:39am UTC](https://discuss.elastic.co/t/question-with-terms-filter/13380/2 "2013-08-29T06:39:18Z")

</div>

Change your mapping and don't analyze your field.

It´s using standard analyzer by default which lowercase your content.

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

Le 29 août 2013 à 03:55, rfq [jsmithy275@gmail.com](mailto:jsmithy275@gmail.com) a écrit :

> I'm using elasticsearch-0.90.3 and had a question with the terms filter.
> 
> I'm storing the id of an author on a comment as such:
> 
> curl -XPUT localhost:9200/comments/comment/1 -d '{ "author" : "qQabqD5yRjCHUOxPgifKVA"}'
> 
> However, when I try to filter by terms using this field, I'm getting nothing back:
> 
> curl -XGET '[http://localhost:9200/comments/\_search](http://localhost:9200/comments/_search)' -d '{  
> "query" : {  
> "filtered" {  
> "filter" : {  
> "terms" : {  
> "author" : ["qQabqD5yRjCHUOxPgifKVA"]  
> }  
> }  
> }  
> }  
> }'
> 
> {"took":0,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max\_score":null,"hits":}}
> 
> If instead, I use a word (or name), it works out, though:
> 
> curl -XPUT localhost:9200/comments/comment/1 -d '{ "author" : "ruben"}'
> 
> curl -XGET '[http://localhost:9200/questions/\_search](http://localhost:9200/questions/_search)' -d '{  
> "query" : {  
> "filtered" : {  
> "filter" : {  
> "terms" : {  
> "author" : ["ruben"]  
> }  
> }  
> }  
> }  
> }'
> 
> {"took":1,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max\_score":1.0,"hits":[{"\_index":"questions","\_type":"question","\_id":"1","\_score":1.0, "\_source" : { "author" : "ruben"}}]}}
> 
> What am I doing wrong?
> 
> Thanks,
> 
> - Ruben
> 
> --  
> 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:19am UTC](https://discuss.elastic.co/t/question-with-terms-filter/13380/3 "2017-07-06T02:19:08Z")

</div>


