# Inaccurate sum aggregation results

**URL:** <https://discuss.elastic.co/t/inaccurate-sum-aggregation-results/128997>\
**Category:** Elasticsearch\
**Created:** [April 22, 2018, 10:45am UTC](https://discuss.elastic.co/t/inaccurate-sum-aggregation-results/128997 "2018-04-22T10:45:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shushu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shushu/32/10037_2.png) [@shushu](https://discuss.elastic.co/u/shushu)\
**Post date:** [April 22, 2018, 10:45am UTC](https://discuss.elastic.co/t/inaccurate-sum-aggregation-results/128997/1 "2018-04-22T10:45:59Z")

</div>

Hi all,  
I index lots of documents in batch mode, indexing ~50M docs.  
Since it took too long (200K/hour) while running on a 5 data nodes cluster, I enlarged the cluster with 2 more data nodes. I was watching while the data "spread" on the new nodes, and all shards re-allocated properly.

When validating the data, I found out that while all of the docs are in the cluster, I fail to get the proper sum results - the numbers are lower.

- I am doing sum aggregation, and I filter by given terms.
- I get different values between different aggregations - when I aggregate by terms and sum the value, I get 3 doc\_counts for this given term. When I filter this term only, I get 4 doc\_counts. It means that for some reason 1 document is kept out of the aggregation.
- When I get the 3 doc\_counts, I get **doc\_count\_error\_upper\_bound=-1**.
- in the \_shards I always get high number of "skipped". I think it just means those shards supposedly does not have relevant docs, but I am not 100% about that.

I am working with elasticsearch for long time, and never encountered this problem.  
I am on 6.2.

Please advise,  
Shushu

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [April 27, 2018, 9:37am UTC](https://discuss.elastic.co/t/inaccurate-sum-aggregation-results/128997/2 "2018-04-27T09:37:25Z")

</div>

Can you supply examples of the 2 JSON queries where you see a discrepancy between them?

---

<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:** [May 25, 2018, 9:37am UTC](https://discuss.elastic.co/t/inaccurate-sum-aggregation-results/128997/3 "2018-05-25T09:37:28Z")

</div>

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