title: term and range filters together in an elasticsearch query
body: <p>In my eleasticsearch index, I have two documents indexed as below:</p>
  
  <pre><code>POST dyn-props/item
  {
      "name": "bar foo",
      "properties": [
          {
              "type": "foo",
              "value": 1.45
          },
  
          {
              "type": "bar",
              "value": 256.34
          },
  
          {
              "type": "foobar",
              "value": 43.43
          }
      ]
  }
  
  POST dyn-props/item
  {
      "name": "foo bar",
      "properties": [
          {
              "type": "foo",
              "value": 33.34
          },
  
          {
              "type": "bar",
              "value": 22.23
          }
      ]
  }
  </code></pre>
  
  <p>On this item type, I would like to query for items which have <strong>foo</strong> property whose value is greater than <strong>10</strong>. I can filter the results down for items that has a property whose type is <strong>foo</strong> with the below query:</p>
  
  <pre><code>POST dyn-props/item/_search
  {
     "query": {
        "filtered": {
           "query": {
              "match_all": {}
           },
           "filter": {
              "term": {
                 "properties.type": "foo"
              }
           }
        }
     }
  }
  </code></pre>
  
  <p>but I am not sure how I can apply the range filter for <strong>value</strong>. Any idea?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Issuing the below query gives me the wrong results as expected:</p>
  
  <pre><code>POST dyn-props/item/_search
  {
     "query": {
        "filtered": {
           "query": {
              "match_all": {}
           },
           "filter": {
             "bool": {
               "must": [
                 {
                    "term": {
                       "properties.type": "foo"
                    }
                 },
  
                  {
                     "range": {
                        "properties.value": {
                          "gte" : 10
                        }
                     }
                  }
               ]
             }
           }
        }
     }
  }
  </code></pre>
  
  <p>The result:</p>
  
  <pre><code>{
     "took": 2,
     "timed_out": false,
     "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
     },
     "hits": {
        "total": 2,
        "max_score": 1,
        "hits": [
           {
              "_index": "dyn-props",
              "_type": "item",
              "_id": "PetPVxwARLOcZqlv28xjpw",
              "_score": 1,
              "_source": {
                 "name": "bar foo",
                 "properties": [
                    {
                       "type": "foo",
                       "value": 1.45
                    },
                    {
                       "type": "bar",
                       "value": 256.34
                    },
                    {
                       "type": "foobar",
                       "value": 43.43
                    }
                 ]
              }
           },
           {
              "_index": "dyn-props",
              "_type": "item",
              "_id": "KqOTXcC9RG6FzPsDDDs8Hw",
              "_score": 1,
              "_source": {
                 "name": "foo bar",
                 "properties": [
                    {
                       "type": "foo",
                       "value": 33.34
                    },
                    {
                       "type": "bar",
                       "value": 22.23
                    }
                 ]
              }
           }
        ]
     }
  }
  </code></pre>