# Combining Filters ES 2.1.1

**URL:** <https://discuss.elastic.co/t/combining-filters-es-2-1-1/54217>\
**Category:** Elasticsearch\
**Created:** [June 28, 2016, 11:56pm UTC](https://discuss.elastic.co/t/combining-filters-es-2-1-1/54217 "2016-06-28T23:56:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![basharz](https://avatars.discourse-cdn.com/v4/letter/b/e99b99/32.png) [@basharz](https://discuss.elastic.co/u/basharz)\
**Post date:** [June 28, 2016, 11:56pm UTC](https://discuss.elastic.co/t/combining-filters-es-2-1-1/54217/1 "2016-06-28T23:56:47Z")

</div>

i have ES version 2.1.1 i tried the below sample query as per the link [https://www.elastic.co/guide/en/elasticsearch/guide/current/combining-filters.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/combining-filters.html)  
but i did not get any results, could anybody explain why, please  
GET /my\_store/products/\_search  
{  
"query" : {  
"constant\_score" : {  
"filter" : {  
"bool" : {  
"should" : [  
{ "term" : {"productID" : "KDKE-B-9947-#kL5"}},  
{ "bool" : {  
"must" : [  
{ "term" : {"productID" : "JODL-X-1937-#pV7"}},  
{ "term" : {"price" : 30}}  
]  
}}  
]  
}  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [July 5, 2016, 6:13am UTC](https://discuss.elastic.co/t/combining-filters-es-2-1-1/54217/2 "2016-07-05T06:13:39Z")

</div>

Hi @basharz,

just double checking: You stored these documents in Elasticsearch before issuing the query, didn't you?

If you look at the [previous page in the docs](https://www.elastic.co/guide/en/elasticsearch/guide/current/_finding_exact_values.html), it shows you how to do it. Here's a complete example copy / pasted from the docs:

```auto
DELETE /my_store 

PUT /my_store 
{
    "mappings" : {
        "products" : {
            "properties" : {
                "productID" : {
                    "type" : "string",
                    "index" : "not_analyzed" 
                }
            }
        }
    }
}

POST /my_store/products/_bulk
{ "index": { "_id": 1 }}
{ "price" : 10, "productID" : "XHDK-A-1293-#fJ3" }
{ "index": { "_id": 2 }}
{ "price" : 20, "productID" : "KDKE-B-9947-#kL5" }
{ "index": { "_id": 3 }}
{ "price" : 30, "productID" : "JODL-X-1937-#pV7" }
{ "index": { "_id": 4 }}
{ "price" : 30, "productID" : "QQPX-R-3956-#aD8" }

GET /my_store/products/_search
{
   "query": {
      "constant_score": {
         "filter": {
            "bool": {
               "should": [
                  {
                     "term": {
                        "productID": "KDKE-B-9947-#kL5"
                     }
                  },
                  {
                     "bool": {
                        "must": [
                           {
                              "term": {
                                 "productID": "JODL-X-1937-#pV7"
                              }
                           },
                           {
                              "term": {
                                 "price": 30
                              }
                           }
                        ]
                     }
                  }
               ]
            }
         }
      }
   }
}

```

Then the query returns two hits:

```auto
{
   "took": 109,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 2,
      "max_score": 1,
      "hits": [
         {
            "_index": "my_store",
            "_type": "products",
            "_id": "2",
            "_score": 1,
            "_source": {
               "price": 20,
               "productID": "KDKE-B-9947-#kL5"
            }
         },
         {
            "_index": "my_store",
            "_type": "products",
            "_id": "3",
            "_score": 1,
            "_source": {
               "price": 30,
               "productID": "JODL-X-1937-#pV7"
            }
         }
      ]
   }
}

```

Daniel

---

<div class="post-metadata">

**Author:** ![basharz](https://avatars.discourse-cdn.com/v4/letter/b/e99b99/32.png) [@basharz](https://discuss.elastic.co/u/basharz)\
**Post date:** [July 6, 2016, 5:59pm UTC](https://discuss.elastic.co/t/combining-filters-es-2-1-1/54217/3 "2016-07-06T17:59:17Z")

</div>

thanks for your replay, actually i already inserted the sample json files to the index and when i try the normal search query it gives me all files  
GET /my\_store/products/\_search{} , it seems the syntax has been changed

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [July 7, 2016, 3:47am UTC](https://discuss.elastic.co/t/combining-filters-es-2-1-1/54217/4 "2016-07-07T03:47:02Z")

</div>

Hi @basharz,

the query syntax changed from 1.x to 2 but AFAIK there were no changes from 2.0 to 2.x in the query syntax. Even if there were, the example that I copy / pasted should also work for you. Can you please try the complete example that I pasted above?

Daniel

---

<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 5, 2017, 10:37pm UTC](https://discuss.elastic.co/t/combining-filters-es-2-1-1/54217/5 "2017-07-05T22:37:29Z")

</div>


