# I cant join a query string and query range

**URL:** <https://discuss.elastic.co/t/i-cant-join-a-query-string-and-query-range/199897>\
**Category:** Kibana\
**Created:** [September 18, 2019, 1:43am UTC](https://discuss.elastic.co/t/i-cant-join-a-query-string-and-query-range/199897 "2019-09-18T01:43:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![andres\_fever](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andres\_fever](https://discuss.elastic.co/u/andres_fever)\
**Post date:** [September 18, 2019, 1:43am UTC](https://discuss.elastic.co/t/i-cant-join-a-query-string-and-query-range/199897/1 "2019-09-18T01:43:38Z")

</div>

I have the following query in dev tools in Kibana that works well for me, without determining a search time.

```auto
GET /example*/_count
{
  "query": {
    "query_string": {
      "query" : "(API002) AND (operation)"
                }
       }
}

```

Now I want to make this query within a specific time but I could not. I try this and with some modifications but it doesn't work for me.

```auto
GET /example*/_count
{
  "query": {
    "query_string": {
      "query" : "(API002) AND (operation)"
           },
              "range" : {
                "gte": "2019-09-16 00:00:00", 
                "lte": "now", 
                "time_zone": "+01:00"
                        }
          }
}

```

---

<div class="post-metadata">

**Author:** ![wangqinghuan](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wangqinghuan](https://discuss.elastic.co/u/wangqinghuan)\
**Post date:** [September 18, 2019, 3:17am UTC](https://discuss.elastic.co/t/i-cant-join-a-query-string-and-query-range/199897/2 "2019-09-18T03:17:45Z")

</div>

You can use bool query to combine mulitple query clause:

```
 GET /example*/_count
  {
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "(API002) AND (operation)"
          }
        },
        {
          "range": {
            "gte": "2019-09-16 00:00:00",
            "lte": "now",
            "time_zone": "+01:00"
          }
        }
      ]
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![andres\_fever](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andres\_fever](https://discuss.elastic.co/u/andres_fever)\
**Post date:** [September 19, 2019, 12:09pm UTC](https://discuss.elastic.co/t/i-cant-join-a-query-string-and-query-range/199897/6 "2019-09-19T12:09:55Z")

</div>

Hello, thanks for your help.  
I used @timestamp.

```
GET /example*/_count
  {
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "(API002) AND (operation)"
          }
        },
        {
          "range": {
            "@timestamp" : {
                "gte" : "now-5760m",
                "lte" : "now",
                "time_zone": "-05:00"
          }
          }
        }
      ]
    }
  }
}

```

Best regards.

---

<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:** [October 17, 2019, 12:09pm UTC](https://discuss.elastic.co/t/i-cant-join-a-query-string-and-query-range/199897/7 "2019-10-17T12:09:55Z")

</div>

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