# Curl witch Aggs and Time

**URL:** <https://discuss.elastic.co/t/curl-witch-aggs-and-time/186106>\
**Category:** Elasticsearch\
**Created:** [June 17, 2019, 3:23pm UTC](https://discuss.elastic.co/t/curl-witch-aggs-and-time/186106 "2019-06-17T15:23:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![schneider](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@schneider](https://discuss.elastic.co/u/schneider)\
**Post date:** [June 17, 2019, 3:23pm UTC](https://discuss.elastic.co/t/curl-witch-aggs-and-time/186106/1 "2019-06-17T15:23:01Z")

</div>

I have a curl that can search the top sender:

```
curl -XGET "http://localhost:9200/_search" -H 'Content-Type: application/json' -d'
{
"size": 0,
"aggs": {
	"group_by_state": {
		"terms": {
			"field": "remetente.keyword"
		}
	}
}
}'

```

and another quem search for a range of date:

```
curl -XGET "http://localhost:9200/_search" -H 'Content-Type: application/json' -d'
{
"aggs":{
	"range": {
		"date_range": {
			"field": "data1",
			"format": "MM-yyy",
			"ranges": [
				{ "to": "now-10M/M" },
				{ "from": "now-10M/M" } 
			]
		}
	}
}
}'

```

i want to make this two curl with one unique curl, someone can help-me?

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [June 18, 2019, 7:09am UTC](https://discuss.elastic.co/t/curl-witch-aggs-and-time/186106/2 "2019-06-18T07:09:18Z")

</div>

Hi,

What about this?

```auto
curl -XGET "http://localhost:9200/_search" -H 'Content-Type: application/json' -d'
{
"size": 0,
"aggs": {
	"group_by_state": {
		"terms": {
			"field": "remetente.keyword"
		}
	},
        "range": {
		"date_range": {
			"field": "data1",
			"format": "MM-yyy",
			"ranges": [
				{ "to": "now-10M/M" },
				{ "from": "now-10M/M" } 
			]
		}
	}
}
}'

```

---

<div class="post-metadata">

**Author:** ![schneider](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@schneider](https://discuss.elastic.co/u/schneider)\
**Post date:** [June 18, 2019, 2:41pm UTC](https://discuss.elastic.co/t/curl-witch-aggs-and-time/186106/3 "2019-06-18T14:41:38Z")

</div>

Thx, now is working fine.

---

<div class="post-metadata">

**Author:** ![schneider](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@schneider](https://discuss.elastic.co/u/schneider)\
**Post date:** [June 18, 2019, 3:57pm UTC](https://discuss.elastic.co/t/curl-witch-aggs-and-time/186106/4 "2019-06-18T15:57:17Z")

</div>

but, the range of date still wrong, for the last 15m of logs, how would it be the data format?  
the format of field data1 is : 'June 18th 2019, 12:39:41.000'.

---

<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 16, 2019, 3:57pm UTC](https://discuss.elastic.co/t/curl-witch-aggs-and-time/186106/5 "2019-07-16T15:57:18Z")

</div>

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