# Multipe terms and date range

**URL:** https://discuss.elastic.co/t/multipe-terms-and-date-range/173125
**Category:** Elasticsearch
**Created:** [March 20, 2019, 11:04am UTC](https://discuss.elastic.co/t/multipe-terms-and-date-range/173125 "2019-03-20T11:04:57Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Ahmad\_Asyary](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmad_asyary/32/41962_2.png) [@Ahmad\_Asyary](https://discuss.elastic.co/u/Ahmad_Asyary)
#### Post date: [March 20, 2019, 11:04am UTC](https://discuss.elastic.co/t/multipe-terms-and-date-range/173125/1 "2019-03-20T11:04:57Z")

</div>

hi, i try to run this query

```
curl -H 'Content-Type: application/json' -XGET 'http://10.42.97.15:9200/project.prod-esb.*/_search?q=logLevel:AUDIT&pretty=true' -d @payload.in
{  
    "_source":["logMessage"],
    "query": {
          "range":{ 
              "@timestamp":{ 
                 "gte":1553068800,
                 "lte":1553069100,
                 "format":"epoch_millis"
              }
            "term": {
                "term":{"kubernetes.container_name":"ordersubmission-bs-v2"}
              }
           }
    }
}

```

But i got error, it said can't use multipe filter. Is there anything wrong with my query? if yes then how it should be look like?

---

<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: [March 20, 2019, 11:19am UTC](https://discuss.elastic.co/t/multipe-terms-and-date-range/173125/2 "2019-03-20T11:19:54Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.  
Please update your post.

You should combine all your queries within a `bool` query under a `must` array.  
Also the `q=logLevel:AUDIT` should be replaced by a `query_string` query that you would also put inside the `must` array. Or a `match` query.

See [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html) for more details about `bool` queries.

---

<div class="post-metadata">

### Author: ![Ahmad\_Asyary](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmad_asyary/32/41962_2.png) [@Ahmad\_Asyary](https://discuss.elastic.co/u/Ahmad_Asyary)
#### Post date: [March 21, 2019, 4:23am UTC](https://discuss.elastic.co/t/multipe-terms-and-date-range/173125/3 "2019-03-21T04:23:07Z")

</div>

Thanks for the correction dadoo. I have try with this query

```
{
  "query": {
    "bool" : {
      "must" : {
        "term":{"kubernetes.container_name":"ordersubmission-bs-v2"},
        "range":{ 
              "@timestamp":{ 
                 "gte":1553068800,
                 "lte":1553069100,
                 "format":"epoch_millis"
              }
          }
    }
  }
}
}

```

But it return malformed query : expected [END\_OBJECT] but found [FIELD\_NAME]

kindly need your help to check if i miss something here

---

<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: [March 21, 2019, 10:11am UTC](https://discuss.elastic.co/t/multipe-terms-and-date-range/173125/4 "2019-03-21T10:11:53Z")

</div>

Try:

```auto
GET test/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "kubernetes.container_name": "ordersubmission-bs-v2"
          }
        },
        {
          "range": {
            "@timestamp": {
              "gte": 1553068800,
              "lte": 1553069100,
              "format": "epoch_millis"
            }
          }
        }
      ]
    }
  }
}

```

---

<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: [April 18, 2019, 10:11am UTC](https://discuss.elastic.co/t/multipe-terms-and-date-range/173125/5 "2019-04-18T10:11:55Z")

</div>

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