Nested terms aggregations - min_doc_count isn't returning key-wise(field in terms) 0 for empty buckets

{

"size": 0,

"aggs" : {

"level_one_aggregation": {

      "date_range": {

          "field": "index_field_one",

          "format": "yyyy-MM-dd",

          "ranges": [{

              "from": "2019-01-01",

              "to": "2020-03-01", 

              "key": "custom-range"

          }],

          "keyed": "true"

      },

  "aggs": {

   "level_two_aggregation": {

        "date_histogram": {

            "field": "index_field_one",

            "interval": "month",

            "min_doc_count": "0",

            "extended_bounds": {

                "min": "2020-01-01",

                "max": "2020-03-01"

            },

            "keyed": "true",

            "order": { "_key": "asc" }

        },

        "aggs": {

            "level_three_aggregation": {

                "terms": {

                    "field": "index_field_two",

                    "include": [1,2,3,4,5],

                    "min_doc_count": "0",

                    "order": { "_key": "asc"}

                },

                "aggs": {

                    "level_three_first_child": {

                        "terms": {

                            "field": "field1",

                            "min_doc_count": "0"

                        }

                    },

                    'sum_of_level_three_first_child': {

                        'sum_bucket': {

                            'buckets_path': 'level_three_first_child>_count'

                        }

                    },

                    'level_three_seond_child': {

                        'terms': {

                            'field': 'field2',

                            'min_doc_count': 0

                        }

                    },

                    'sum_of_level_three_second_child': {

                        'sum_bucket': {

                            'buckets_path': 'level_three_seond_child>_count'

                        }

                    }

                }

            }

        }

    }

  }

}  

}

}

In single level terms aggregation the min_doc_count gives a zero count corresponding to each field in "index_field_two" but in the above snippet the min_doc_count gives an empty bucket but fails to give zero count corresponding to each field in index_field_two of level_three_aggregation for level_three_first_child and level_three_second_child. Have tried using missing, include paired with min_doc_count, changing its size(isn't relevant though). How can I get this working??

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