# Elasticsearch error: Validation Failed: 1: parent histogram of moving\_avg aggregation \[3\] must have min\_doc\_count of 0;

**URL:** <https://discuss.elastic.co/t/elasticsearch-error-validation-failed-1-parent-histogram-of-moving-avg-aggregation-3-must-have-min-doc-count-of-0/274033>\
**Category:** Elasticsearch\
**Created:** [May 26, 2021, 9:38am UTC](https://discuss.elastic.co/t/elasticsearch-error-validation-failed-1-parent-histogram-of-moving-avg-aggregation-3-must-have-min-doc-count-of-0/274033 "2021-05-26T09:38:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isekai](https://avatars.discourse-cdn.com/v4/letter/i/eb9ed0/32.png) [@Isekai](https://discuss.elastic.co/u/Isekai)\
**Post date:** [May 26, 2021, 9:38am UTC](https://discuss.elastic.co/t/elasticsearch-error-validation-failed-1-parent-histogram-of-moving-avg-aggregation-3-must-have-min-doc-count-of-0/274033/1 "2021-05-26T09:38:38Z")

</div>

Greetings everyone  
Yesterday we updated elastic from 7.4.x to 7.10.1 and some of our grafana dashboards broke with the following error:

> Elasticsearch error: Validation Failed: 1: parent histogram of moving\_avg aggregation [3] must have min\_doc\_count of 0;

The dashboard used to represent a moving average and had a min\_doc\_count of 20 to exclude weekends.  
But now it does not work after the update.  
We also updated our grafana from 6.x to 7.x, but i'm not sure if grafana is the culprit here.

I understood that the moving average aggregate cannot have min\_doc\_count higher than 0, and if i set it to 0, it works.  
But how come in 7.4.x it worked and 7.10.1 it does not work?

Thank you for your help.  
A snip of the query:

```auto
"aggs":{
   "2":{
      "date_histogram":{
         "interval":"1d",
         "field":"metadata.timestamp",
         "min_doc_count":"20",
         "extended_bounds":{
            "min":1614248733448,
            "max":1622021133448
         },
         "format":"epoch_millis"
      },
      "aggs":{
         "1":{
            "avg":{
               "field":"some_variable_in_minutes",
               "script":"(_value < 30) ? 100: 0"
            }
         },
         "3":{
            "moving_avg":{
               "buckets_path":"1",
               "minimize":false,
               "model":"simple",
               "window":5
            }
         }
      }
   }
}

```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 26, 2021, 10:00am UTC](https://discuss.elastic.co/t/elasticsearch-error-validation-failed-1-parent-histogram-of-moving-avg-aggregation-3-must-have-min-doc-count-of-0/274033/2 "2021-05-26T10:00:36Z")

</div>

Hey,

would it be possible to create a fully reproducible example, test this under the latest release (7.13.0) and if that fails open a github issue at [Issues · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues) - also include the exact version where the same query was still working.

Thank you!

--Alex

---

<div class="post-metadata">

**Author:** ![Isekai](https://avatars.discourse-cdn.com/v4/letter/i/eb9ed0/32.png) [@Isekai](https://discuss.elastic.co/u/Isekai)\
**Post date:** [June 7, 2021, 8:54pm UTC](https://discuss.elastic.co/t/elasticsearch-error-validation-failed-1-parent-histogram-of-moving-avg-aggregation-3-must-have-min-doc-count-of-0/274033/3 "2021-06-07T20:54:24Z")

</div>

Tested the query on a local machine on elastic 7.4.2 and it works fine.  
Tested it again on a local machine, but on 7.10.1 and it returns the mentioned error.  
It seems between 7.4.2 and 7.10.1 it was decided to not allow the min\_doc\_count to be higher than 0 on moving\_fn or date\_histograms.  
The only documentation that clearly states this is on Derivative aggregation:

> **[Derivative aggregation | Elasticsearch Guide \[7.13\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.13/search-aggregations-pipeline-derivative-aggregation.html#search-aggregations-pipeline-derivative-aggregation)**

I would recommend to close this issue as i decided not to pursue further for now.  
Thank you for your collaboration.

---

<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 5, 2021, 8:55pm UTC](https://discuss.elastic.co/t/elasticsearch-error-validation-failed-1-parent-histogram-of-moving-avg-aggregation-3-must-have-min-doc-count-of-0/274033/4 "2021-07-05T20:55:02Z")

</div>

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