elastic/elasticsearch · error · IllegalArgumentException

minimum_interval must be one of [{ALLOWED_INTERVALS.values()

Error message

minimum_interval must be one of [{ALLOWED_INTERVALS.values()}]

What it means

Thrown by AutoDateHistogramAggregationBuilder.setMinimumIntervalExpression when the supplied value is non-null but not one of the allowed intervals. Allowed values are the strings in ALLOWED_INTERVALS: year, month, day, hour, minute, second. The minimum_interval caps the granularity the auto-calculator is allowed to use.

Source

Thrown at modules/aggregations/src/main/java/org/elasticsearch/aggregations/bucket/histogram/AutoDateHistogramAggregationBuilder.java:171

    }

    @Override
    protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
        return new AutoDateHistogramAggregationBuilder(this, factoriesBuilder, metadata);
    }

    @Override
    public String getType() {
        return NAME;
    }

    public String getMinimumIntervalExpression() {
        return minimumIntervalExpression;
    }

    public AutoDateHistogramAggregationBuilder setMinimumIntervalExpression(String minimumIntervalExpression) {
        if (minimumIntervalExpression != null && ALLOWED_INTERVALS.containsValue(minimumIntervalExpression) == false) {
            throw new IllegalArgumentException(
                MINIMUM_INTERVAL_FIELD.getPreferredName() + " must be one of [" + ALLOWED_INTERVALS.values() + "]"
            );
        }
        this.minimumIntervalExpression = minimumIntervalExpression;
        return this;
    }

    public AutoDateHistogramAggregationBuilder setNumBuckets(int numBuckets) {
        if (numBuckets <= 0) {
            throw new IllegalArgumentException(NUM_BUCKETS_FIELD.getPreferredName() + " must be greater than 0 for [" + name + "]");
        }
        this.numBuckets = numBuckets;
        return this;
    }

    @Override
    public BucketCardinality bucketCardinality() {
        return BucketCardinality.MANY;

View on GitHub (pinned to db6a809a66)

Solutions

  1. Use one of the six allowed values: year, month, day, hour, minute, second.
  2. Omit minimum_interval entirely if you want the aggregation to auto-select any granularity.
  3. Validate the value client-side against the allowed set before submitting.

Example fix

// before
{"auto_date_histogram":{"field":"@timestamp","minimum_interval":"week"}}
// after
{"auto_date_histogram":{"field":"@timestamp","minimum_interval":"day"}}
Defensive patterns

Strategy: validation

Validate before calling

Set<String> ALLOWED = Set.of("year","month","day","hour","minute","second");
if (minimumInterval != null && !ALLOWED.contains(minimumInterval)) {
  throw new IllegalArgumentException("minimum_interval must be one of " + ALLOWED);
}

Type guard

boolean isValidMinimumInterval(String s) {
  return s == null || Set.of("year","month","day","hour","minute","second").contains(s);
}

Prevention

When it happens

Trigger: Calling `setMinimumIntervalExpression("week")`, `"quarter"`, `"millisecond"`, or any typo. Submitting a REST request with `"minimum_interval": "weeks"` (plural or wrong unit).

Common situations: Users assuming the auto_date_histogram supports the same intervals as the regular date_histogram (which allows more units like week, quarter, fiscal periods). Pluralization typos. Copy-paste from date_histogram configurations.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/b70b3a1836bd3677. Report an issue: GitHub.