# Elasticsearch filter

**URL:** <https://discuss.elastic.co/t/elasticsearch-filter/68398>\
**Category:** Elasticsearch\
**Created:** [December 8, 2016, 7:19am UTC](https://discuss.elastic.co/t/elasticsearch-filter/68398 "2016-12-08T07:19:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![parthimails](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@parthimails](https://discuss.elastic.co/u/parthimails)\
**Post date:** [December 8, 2016, 7:19am UTC](https://discuss.elastic.co/t/elasticsearch-filter/68398/1 "2016-12-08T07:19:11Z")

</div>

I am trying to filter documents which has productid = 0 (type: String)  
But I getting results which includes 10, 20,30 etc. I need only the ProductID =0 . I was referring the below URL . I tried this in sense.  
How should i modify to just get documents with productid = 0?  
GET /merge\_14/data/\_search  
{  
"query" : {  
"constant\_score" : {  
"filter" : {  
"term" : {  
"productID" : 0  
}  
}  
}  
}  
}

[https://www.elastic.co/guide/en/elasticsearch/guide/current/\_finding\_exact\_values.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/_finding_exact_values.html)

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [December 9, 2016, 6:41pm UTC](https://discuss.elastic.co/t/elasticsearch-filter/68398/2 "2016-12-09T18:41:34Z")

</div>

A filter that should work would be:

```
GET /merge_14/data/_search
{
  "query" : {
    "bool" : {
      "filter" : [
        {
          "term" : {
            "productID" : 0
          }
        }
      ]
    }
  }
}
```

---

<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:** [January 6, 2017, 6:42pm UTC](https://discuss.elastic.co/t/elasticsearch-filter/68398/3 "2017-01-06T18:42:10Z")

</div>

Closed on January 6, 2017, 6:42pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
