How to return whole date range in Date Histogram aggegation

I am using Date Histogram to aggregation values over time. The problem is that I see that if that date has no data, it just omits it completely. What I need it to do is enter it as null. I try to use missing and also min_doc_count set to 0 but the result is still the same.

Partial requests:

"aggs": {
            "winner_over_time": {
                "terms": {
                    "field": "winner",
                    "size": 10,
                    "order": {
                        "_term": "asc"
                    }
                },
                "aggs": {
                    "count_over_time": {
                        "date_histogram": {
                            "field": "timestamp",
                            "interval": interval,
                            "min_doc_count": 0,
                            "missing": 0
                        }
                    }
                }
            },

Partial response:

    "aggregations": {
        "winner_over_time": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
                {
                    "key": -3,
                    "doc_count": 1,
                    "count_over_time": {
                        "buckets": [
                            {
                                "key_as_string": "2018-01-29T05:00:00.000Z",
                                "key": 1517202000000,
                                "doc_count": 1
                            }
                        ]
                    }
                },
                {
                    "key": -1,
                    "doc_count": 3,
                    "count_over_time": {
                        "buckets": [
                            {
                                "key_as_string": "2018-01-29T00:00:00.000Z",
                                "key": 1517184000000,
                                "doc_count": 1
                            },
                            {
                                "key_as_string": "2018-01-29T01:00:00.000Z",
                                "key": 1517187600000,
                                "doc_count": 1
                            },
                            {
                                "key_as_string": "2018-01-29T02:00:00.000Z",
                                "key": 1517191200000,
                                "doc_count": 0
                            },
                            {
                                "key_as_string": "2018-01-29T03:00:00.000Z",
                                "key": 1517194800000,
                                "doc_count": 0
                            },
                            {
                                "key_as_string": "2018-01-29T04:00:00.000Z",
                                "key": 1517198400000,
                                "doc_count": 0
                            },
                            {
                                "key_as_string": "2018-01-29T05:00:00.000Z",
                                "key": 1517202000000,
                                "doc_count": 1
                            }
                        ]
                    }
                },

As you see, for "key": -3, it only returned one data point for me. I need it to return everything within the series. Right now I had to go into the data and manually insert missing time keys for my charting library. I would prefer to not have to do that.

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