# Question about extended\_stats aggregation

**URL:** <https://discuss.elastic.co/t/question-about-extended-stats-aggregation/72877>\
**Category:** Elasticsearch\
**Created:** [January 26, 2017, 10:11am UTC](https://discuss.elastic.co/t/question-about-extended-stats-aggregation/72877 "2017-01-26T10:11:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wdc](https://avatars.discourse-cdn.com/v4/letter/w/9e8a1a/32.png) [@wdc](https://discuss.elastic.co/u/wdc)\
**Post date:** [January 26, 2017, 10:11am UTC](https://discuss.elastic.co/t/question-about-extended-stats-aggregation/72877/1 "2017-01-26T10:11:43Z")

</div>

I am using Elasticsearch 2.3.3 and execute the following query:  
POST ems-metrics-\*/metric/\_search?preference=\_primary  
{  
"size": 100,  
"query": {  
"constant\_score": {  
"filter": {  
"bool": {  
"must": [  
{  
"match": {  
"method": "consumerLag"  
}  
},  
{  
"range": {  
"@timestamp": {  
"gte": 1485244800000,  
"lte": 1485244860000,  
"format": "epoch\_millis"  
}  
}  
}  
]  
}  
}  
}  
},  
"aggs": {  
"facts\_by\_interval": {  
"date\_histogram": {  
"field": "@timestamp",  
"interval": "minute"  
},  
"aggs": {  
"occurences": {  
"filters": {  
"filters": {  
"within\_sla": {  
"range": {  
"value": {  
"lte": 0  
}  
}  
}  
}  
}  
}  
}  
},  
"stats\_by\_interval": {  
"date\_histogram": {  
"field": "@timestamp",  
"interval": "minute"  
},  
"aggs": {  
"stats": {  
"extended\_stats": {  
"field": "value"  
}  
}  
}  
}  
}  
}

which in return gives me the following [search result](https://gist.github.com/anonymous/228ac57a632e5f11695510363af774f8)  
In which I think the extended stats contain errors: both the count and sum values within 'stats\_by\_interval' seem to be the exact double of what I expect them to be.

The 'facts\_by\_interval' aggregation however seems to be correct.

Any insight on this ?

---

<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:** [February 23, 2017, 10:11am UTC](https://discuss.elastic.co/t/question-about-extended-stats-aggregation/72877/2 "2017-02-23T10:11:51Z")

</div>

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