# Help with query (range)

**URL:** <https://discuss.elastic.co/t/help-with-query-range/160901>\
**Category:** Elasticsearch\
**Created:** [December 14, 2018, 12:01pm UTC](https://discuss.elastic.co/t/help-with-query-range/160901 "2018-12-14T12:01:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PolterFox](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polterfox/32/29781_2.png) [@PolterFox](https://discuss.elastic.co/u/PolterFox)\
**Post date:** [December 14, 2018, 12:01pm UTC](https://discuss.elastic.co/t/help-with-query-range/160901/1 "2018-12-14T12:01:20Z")

</div>

Hey guys,

I need some help with a query. I´ve created a query which looks for are specific range of my property Ping (values greater or equal 1000), but it also needs to be in the last 1 hour. How can I achieve this result?

Here is my query:

```
"body": {
 "query": {
  "range": {
   "Ping": {
    "gte": 1000
   }
  }
 }
}
```

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [December 14, 2018, 1:28pm UTC](https://discuss.elastic.co/t/help-with-query-range/160901/2 "2018-12-14T13:28:30Z")

</div>

Hi,

Move your query into a BoolQuery, in a must condition, and add another range query on the time field with value = `now-1h`;

Bool query  
[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)

Time manipulation  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math)

bye,  
Xavier

---

<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:** [January 11, 2019, 1:28pm UTC](https://discuss.elastic.co/t/help-with-query-range/160901/3 "2019-01-11T13:28:38Z")

</div>

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