# Range Aggregation - Default 'key' \[ES 1.1.1\]

**URL:** <https://discuss.elastic.co/t/range-aggregation-default-key-es-1-1-1/22214>\
**Category:** Elasticsearch\
**Created:** [February 17, 2015, 5:39pm UTC](https://discuss.elastic.co/t/range-aggregation-default-key-es-1-1-1/22214 "2015-02-17T17:39:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_R](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scott_r/32/893_2.png) [@Scott\_R](https://discuss.elastic.co/u/Scott_R)\
**Post date:** [February 17, 2015, 5:39pm UTC](https://discuss.elastic.co/t/range-aggregation-default-key-es-1-1-1/22214/1 "2015-02-17T17:39:16Z")

</div>

In running the following range aggregation [choosing not to specify a 'key'  
for each range]

{  
"query": {  
"match\_all": {}  
},  
"aggs": {  
"duration": {  
"range": {  
"field": "duration",  
"ranges": [  
{ "to": 60 },  
{ "from": 60, "to": 300},  
{ "from": 300, "to": 900},  
{ "from": 900, "to": 3600},  
{ "from": 3600 }  
]  
}  
}  
}  
}

I seem to be alternating between two result sets, the first request will  
return:  
"aggregations": {  
"duration": {  
"buckets": [  
{  
"to": 60,  
"doc\_count": 157680  
},  
{  
"from": 60,  
"to": 300,  
"doc\_count": 181398  
},  
{  
"from": 300,  
"to": 900,  
"doc\_count": 39937  
},  
{  
"from": 900,  
"to": 3600,  
"doc\_count": 8809  
},  
{  
"from": 3600,  
"doc\_count": 298  
}  
]  
}  
}

And the subsequent request will return:  
"aggregations": {  
"duration": {  
"buckets": [  
{  
"key": "_-60.0",  
"to": 60,  
"doc\_count": 157680  
},  
{  
"key": "60.0-300.0",  
"from": 60,  
"to": 300,  
"doc\_count": 181398  
},  
{  
"key": "300.0-900.0",  
"from": 300,  
"to": 900,  
"doc\_count": 39937  
},  
{  
"key": "900.0-3600.0",  
"from": 900,  
"to": 3600,  
"doc\_count": 8809  
},  
{  
"key": "3600.0-_",  
"from": 3600,  
"doc\_count": 298  
}  
]  
}  
}

Each request afterwards alternates between "key" being absent from each  
bucket in the list and then being present. Was hoping someone might have  
some insight as to what is going on just to satisfy my own curiosity.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/840a3619-2736-49e9-97b3-06a5b2fea9d7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/840a3619-2736-49e9-97b3-06a5b2fea9d7%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [February 18, 2015, 12:36pm UTC](https://discuss.elastic.co/t/range-aggregation-default-key-es-1-1-1/22214/2 "2015-02-18T12:36:17Z")

</div>

How many nodes do you have in your cluster?

If you have 2 nodes then it would suggest that there is something different  
between the two nodes which is causing this and your request is alternating  
between each of the nodes.

My first guess would be that the nodes are accidentally on different  
versions.

I would start by using the nodes API to confirm the nodes are all on the  
same version of Elasticsearch:

curl -XGET "[http://localhost:9200/\_nodes/settings](http://localhost:9200/_nodes/settings)"

Hope this helps

Colin

On Tuesday, 17 February 2015 17:39:16 UTC, Scott Rallya wrote:

> In running the following range aggregation [choosing not to specify a  
> 'key' for each range]
> 
> {  
> "query": {  
> "match\_all": {}  
> },  
> "aggs": {  
> "duration": {  
> "range": {  
> "field": "duration",  
> "ranges": [  
> { "to": 60 },  
> { "from": 60, "to": 300},  
> { "from": 300, "to": 900},  
> { "from": 900, "to": 3600},  
> { "from": 3600 }  
> ]  
> }  
> }  
> }  
> }
> 
> I seem to be alternating between two result sets, the first request will  
> return:  
> "aggregations": {  
> "duration": {  
> "buckets": [  
> {  
> "to": 60,  
> "doc\_count": 157680  
> },  
> {  
> "from": 60,  
> "to": 300,  
> "doc\_count": 181398  
> },  
> {  
> "from": 300,  
> "to": 900,  
> "doc\_count": 39937  
> },  
> {  
> "from": 900,  
> "to": 3600,  
> "doc\_count": 8809  
> },  
> {  
> "from": 3600,  
> "doc\_count": 298  
> }  
> ]  
> }  
> }
> 
> And the subsequent request will return:  
> "aggregations": {  
> "duration": {  
> "buckets": [  
> {  
> "key": "_-60.0",  
> "to": 60,  
> "doc\_count": 157680  
> },  
> {  
> "key": "60.0-300.0",  
> "from": 60,  
> "to": 300,  
> "doc\_count": 181398  
> },  
> {  
> "key": "300.0-900.0",  
> "from": 300,  
> "to": 900,  
> "doc\_count": 39937  
> },  
> {  
> "key": "900.0-3600.0",  
> "from": 900,  
> "to": 3600,  
> "doc\_count": 8809  
> },  
> {  
> "key": "3600.0-_",  
> "from": 3600,  
> "doc\_count": 298  
> }  
> ]  
> }  
> }
> 
> Each request afterwards alternates between "key" being absent from each  
> bucket in the list and then being present. Was hoping someone might have  
> some insight as to what is going on just to satisfy my own curiosity.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/65724db4-f1a0-4015-8a3d-924c7b1f73a2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/65724db4-f1a0-4015-8a3d-924c7b1f73a2%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:31am UTC](https://discuss.elastic.co/t/range-aggregation-default-key-es-1-1-1/22214/3 "2017-07-06T00:31:55Z")

</div>


