# How to reduce doc\_count\_error\_upper\_bound to 0

**URL:** https://discuss.elastic.co/t/how-to-reduce-doc-count-error-upper-bound-to-0/221130
**Category:** Elasticsearch
**Created:** [February 27, 2020, 2:23am UTC](https://discuss.elastic.co/t/how-to-reduce-doc-count-error-upper-bound-to-0/221130 "2020-02-27T02:23:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Udayabharathi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/udayabharathi/32/61917_2.png) [@Udayabharathi](https://discuss.elastic.co/u/Udayabharathi)
#### Post date: [February 27, 2020, 2:23am UTC](https://discuss.elastic.co/t/how-to-reduce-doc-count-error-upper-bound-to-0/221130/1 "2020-02-27T02:23:09Z")

</div>

I'm new to elasticsearch and I recently came across this **doc\_count\_error\_upper\_bound** in the results. When I tried to aggregate the data using terms based on a field with sorting based on descending count and limited the data to size 10, I had **doc\_count\_error\_upper\_bound** as **10** on the result. This leads me to verify the correctness of the count data in the result. When I verified it was only approximate and not accurate. I came across the elasticsearch docs where I found that ES uses shards to store the data and I understood it is based on the size that the accuracy of the results varies. I can easily increase the size given to reduce the error upper bound. My question is **whether we have a way to reduce the number of shards being used** and if so, **is reducing the number of shards used for accuracy the right way?** Also, I want to know **how the performance degrades when we reduce the shards?** I've attached the query and the result too.

Query:

> ```
> {
> "size": 0,
> "aggs": {
> "2": {
> "terms": {
> "field": "...",
> "order": {
> "_count": "desc"
> },
> "size": 10
> }
> }
> },
> "_source": {},
> "sort": [],
> "query": {
> "constant_score": {
> "filter": {
> "bool": {
> "must": [
> ...
> ],
> "should": [],
> "must_not": [
> ...
> ]
> }
> }
> }
> }
> }
> 
> ```

Response:

> ```
> {
> "took" : 7,
> "timed_out" : false,
> "_shards" : {
> "total" : 5,
> "successful" : 5,
> "skipped" : 0,
> "failed" : 0
> },
> "hits" : {
> "total" : {
> "value" : 7692,
> "relation" : "eq"
> },
> "max_score" : null,
> "hits" : []
> },
> "aggregations" : {
> "2" : {
> "doc_count_error_upper_bound" : 15,
> "sum_other_doc_count" : 6596,
> "buckets" : [
> ...
> ]
> }
> }
> }
> 
> ```

---

<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: [March 26, 2020, 2:23am UTC](https://discuss.elastic.co/t/how-to-reduce-doc-count-error-upper-bound-to-0/221130/2 "2020-03-26T02:23:19Z")

</div>

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