Browse Source

Do not generate empty buckets for the date histogram (#89070)

If the date histogram interval is large and the 'fixed_interval'
parameter is very small we might end up with a large number of
buckets in the resulting histogram, in case we also generate empty
buckets. As a result of this we might generate too many buckets
(max date - min date) / fixed_interval > 65536 (roughly)..

Here we set minDocCount to 1 so to avoid generation of empty buckets.
In the test the maximum value for 'docCount' is 9000 which means,
in the worst case we generate 9000 documents, each belonging to a
different bucket. In this case we would have 9000 buckets maximum
which is well below the default maximum number of buckets allowed by
default.
Salvatore Campagna 3 years ago
parent
commit
36c4a17087

+ 1 - 1
x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/v2/RollupActionSingleNodeTests.java

@@ -818,7 +818,7 @@ public class RollupActionSingleNodeTests extends ESSingleNodeTestCase {
             .size(10_000);
         final DateHistogramAggregationBuilder dateHistogramAggregation = new DateHistogramAggregationBuilder("timestamp").field(
             config.getTimestampField()
-        ).fixedInterval(config.getInterval());
+        ).fixedInterval(config.getInterval()).minDocCount(1);
         if (config.getTimeZone() != null) {
             dateHistogramAggregation.timeZone(ZoneId.of(config.getTimeZone()));
         }