# Question with terms filters and ids

**URL:** <https://discuss.elastic.co/t/question-with-terms-filters-and-ids/13381>\
**Category:** Elasticsearch\
**Created:** [August 29, 2013, 2:07am UTC](https://discuss.elastic.co/t/question-with-terms-filters-and-ids/13381 "2013-08-29T02:07:10Z")\
**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, 2:07am UTC](https://discuss.elastic.co/t/question-with-terms-filters-and-ids/13381/1 "2013-08-29T02:07:10Z")

</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/comments/\_search](http://localhost:9200/comments/_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":"comments","\_type": "comment","\_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:** ![sina\_tamanna](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@sina\_tamanna](https://discuss.elastic.co/u/sina_tamanna)\
**Post date:** [August 29, 2013, 7:00am UTC](https://discuss.elastic.co/t/question-with-terms-filters-and-ids/13381/2 "2013-08-29T07:00:44Z")

</div>

The reason is that you are using the default analyzer to store your  
document. So when you put 'qQabqD5yRjCHUOxPgifKVA' in the index, it is  
actually stored as 'qqabqd5yrjchuoxpgifkva'. Later when you search the  
original with term query, unanalyzed, it tries to match it to the exact  
lower case document and it fails. You could repeat the last query with '  
qqabqd5yrjchuoxpgifkva' and you will get result.

Obviously this is not the case for 'ruben' since it is lowercase.

--  
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-filters-and-ids/13381/3 "2017-07-06T02:19:07Z")

</div>


