# A problem when I search data from "now-24h" to "now"

**URL:** https://discuss.elastic.co/t/a-problem-when-i-search-data-from-now-24h-to-now/136843
**Category:** Elasticsearch
**Created:** [June 21, 2018, 12:02pm UTC](https://discuss.elastic.co/t/a-problem-when-i-search-data-from-now-24h-to-now/136843 "2018-06-21T12:02:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Kevin.Wu](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@Kevin.Wu](https://discuss.elastic.co/u/Kevin.Wu)
#### Post date: [June 21, 2018, 12:02pm UTC](https://discuss.elastic.co/t/a-problem-when-i-search-data-from-now-24h-to-now/136843/1 "2018-06-21T12:02:34Z")

</div>

Hey, I'm trying to search some data from ES, here's my curl command from kibana:

> GET filebeat\*/\_search?size=0  
> {  
> "query":{  
> "bool": {  
> "filter": {  
> "range": {  
> "@timestamp": {  
> "gte": "now-24h",  
> "lte": "now"  
> }  
> }  
> }  
> }  
> },  
> "aggs": {  
> "peers\_per\_hour": {  
> "date\_histogram": {  
> "field": "@timestamp",  
> "interval": "hour",  
> "format": "yyyy-MM-dd:HH:mm",  
> "min\_doc\_count": 0  
> },  
> "aggs": {  
> "peers": {  
> "avg": {  
> "field": "peers"  
> }  
> }  
> }  
> }  
> }  
> }

And here's what I got:

> "aggregations": {  
> "peers\_per\_hour": {  
> "buckets": [  
> {  
> "key\_as\_string": "2018-06-21:07:00",  
> "key": 1529564400000,  
> "doc\_count": 20,  
> "peers": {  
> "value": 216.85  
> }  
> },  
> {  
> "key\_as\_string": "2018-06-21:08:00",  
> "key": 1529568000000,  
> "doc\_count": 22,  
> "peers": {  
> "value": 216.85  
> }  
> },  
> {  
> "key\_as\_string": "2018-06-21:09:00",  
> "key": 1529571600000,  
> "doc\_count": 21,  
> "peers": {  
> "value": 49.9  
> }  
> },  
> {  
> "key\_as\_string": "2018-06-21:10:00",  
> "key": 1529575200000,  
> "doc\_count": 45,  
> "peers": {  
> "value": 209.20454545454547  
> }  
> },  
> {  
> "key\_as\_string": "2018-06-21:11:00",  
> "key": 1529578800000,  
> "doc\_count": 43,  
> "peers": {  
> "value": 215.71428571428572  
> }  
> }  
> ]  
> }  
> }

I want the last 24-hour data, but ES only return 5 buckets, any thing wrong with my command ?  
Thanks!

---

<div class="post-metadata">

### Author: ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)
#### Post date: [June 29, 2018, 11:05am UTC](https://discuss.elastic.co/t/a-problem-when-i-search-data-from-now-24h-to-now/136843/2 "2018-06-29T11:05:12Z")

</div>

> [@Kevin.Wu](#):
>
> "interval": "hour",

Don't use `hour` as the aggregation interval if you want larger buckets (e.g. days) in the aggregation.

---

<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: [July 27, 2018, 11:10am UTC](https://discuss.elastic.co/t/a-problem-when-i-search-data-from-now-24h-to-now/136843/3 "2018-07-27T11:10:32Z")

</div>

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