# Elasticsearch query - documents ingested across all indexes in last 1h

**URL:** https://discuss.elastic.co/t/elasticsearch-query-documents-ingested-across-all-indexes-in-last-1h/186875
**Category:** Elasticsearch
**Created:** [June 21, 2019, 12:10pm UTC](https://discuss.elastic.co/t/elasticsearch-query-documents-ingested-across-all-indexes-in-last-1h/186875 "2019-06-21T12:10:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![pastechecker](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pastechecker](https://discuss.elastic.co/u/pastechecker)
#### Post date: [June 21, 2019, 12:10pm UTC](https://discuss.elastic.co/t/elasticsearch-query-documents-ingested-across-all-indexes-in-last-1h/186875/1 "2019-06-21T12:10:04Z")

</div>

Hello.  
I am attempting to write a query that will count me a documents across all indexes starting with url\* in last 1h.

> GET urls\*/\_count  
> {  
> "query": {  
> "range" : {  
> "@timestamp" : {  
> "gte" : "now-5m",  
> "lt" : "now"  
> }  
> }  
> }  
> }

Result:

> {  
> "count" : 121075,  
> "\_shards" : {  
> "total" : 96,  
> "successful" : 96,  
> "skipped" : 0,  
> "failed" : 0  
> }  
> }

This is great, but I would like to get the aggregation per index name.

> GET urls\*/\_search  
> {"size":0,"aggs":{"byindex":{"terms":{"field":"\_index"}}}}

Gives me:

> {  
> "took": 177,  
> "timed\_out": false,  
> "\_shards": {  
> "total": 96,  
> "successful": 96,  
> "skipped": 0,  
> "failed": 0  
> },  
> "hits": {  
> "total": {  
> "value": 10000,  
> "relation": "gte"  
> },  
> "max\_score": null,  
> "hits":   
> },  
> "aggregations": {  
> "byindex": {  
> "doc\_count\_error\_upper\_bound": 0,  
> "sum\_other\_doc\_count": 17568531,  
> "buckets": [{  
> "key": "urls-2019-06-20",  
> "doc\_count": 15218939  
> }, {  
> "key": "urls-2019-06-19",  
> "doc\_count": 14521050  
> }  
> ........  
> ]  
> }  
> }  
> }

How should I add the date do the aggregation?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [June 23, 2019, 11:06am UTC](https://discuss.elastic.co/t/elasticsearch-query-documents-ingested-across-all-indexes-in-last-1h/186875/2 "2019-06-23T11:06:41Z")

</div>

Are you looking for [something like this](https://stackoverflow.com/questions/34304443/elastic-search-aggregation-group-by-index)?

---

<div class="post-metadata">

### Author: ![pastechecker](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pastechecker](https://discuss.elastic.co/u/pastechecker)
#### Post date: [June 25, 2019, 8:00am UTC](https://discuss.elastic.co/t/elasticsearch-query-documents-ingested-across-all-indexes-in-last-1h/186875/3 "2019-06-25T08:00:42Z")

</div>

Thx.

---

<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 23, 2019, 8:00am UTC](https://discuss.elastic.co/t/elasticsearch-query-documents-ingested-across-all-indexes-in-last-1h/186875/4 "2019-07-23T08:00:50Z")

</div>

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