# Query string with range

**URL:** <https://discuss.elastic.co/t/query-string-with-range/85111>\
**Category:** Elasticsearch\
**Created:** [May 9, 2017, 2:15pm UTC](https://discuss.elastic.co/t/query-string-with-range/85111 "2017-05-09T14:15:33Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![lwintergerst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lwintergerst/32/18164_2.png) [@lwintergerst](https://discuss.elastic.co/u/lwintergerst)\
**Post date:** [May 9, 2017, 2:33pm UTC](https://discuss.elastic.co/t/query-string-with-range/85111/2 "2017-05-09T14:33:15Z")

</div>

If you want to combine multiple queries - in this case the range and the query string - you will have to wrap them in a bool query. This is how the correct query will look like:

> ```
> {
> "query": {
> "bool": {
> "must": [
> {
> "query_string": {
> "analyze_wildcard": true,
> "query": "failed to add key to cache"
> }
> },
> {
> "range": {
> "@timestamp": {
> "gte": "now-500d"
> }
> }
> }
> ]
> }
> }
> }
> 
> ```

---

_[View the full topic](https://discuss.elastic.co/t/query-string-with-range/85111)._
