elastic/elasticsearch · error · IllegalArgumentException
[size] must be greater than 0. Found [{size}] in [{name}]
Error message
[size] must be greater than 0. Found [{size}] in [{name}] What it means
Thrown by TimeSeriesAggregationBuilder.setSize when size <= 0. The time_series aggregation groups documents into time-series buckets and requires a positive size to bound the number of series tracked. Zero or negative is meaningless for the internal data structures.
Source
Thrown at modules/aggregations/src/main/java/org/elasticsearch/aggregations/bucket/timeseries/TimeSeriesAggregationBuilder.java:131
@Override
public BucketCardinality bucketCardinality() {
return BucketCardinality.MANY;
}
@Override
public String getType() {
return NAME;
}
@Override
public boolean isInSortOrderExecutionRequired() {
return true;
}
public TimeSeriesAggregationBuilder setSize(int size) {
if (size <= 0) {
throw new IllegalArgumentException("[size] must be greater than 0. Found [" + size + "] in [" + name + "]");
}
this.size = size;
return this;
}
public int getSize() {
return size;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (super.equals(o) == false) return false;
TimeSeriesAggregationBuilder that = (TimeSeriesAggregationBuilder) o;
return keyed == that.keyed && size == that.size;
}
View on GitHub (pinned to db6a809a66)
Solutions
- Set size to a positive integer reflecting the maximum number of time series to track.
- Validate that any computed size is >= 1 before calling setSize.
- Default to a reasonable positive value (e.g. the documented default) when input is absent or zero.
Example fix
// before
{"time_series":{"size":0,...}}
// after
{"time_series":{"size":10000,...}} Defensive patterns
Strategy: validation
Validate before calling
if (size <= 0) {
throw new IllegalArgumentException("time_series size must be > 0");
} Prevention
- Default computed sizes to a positive integer.
- Validate configuration variables for positivity before setSize.
- Treat zero as unset and substitute a sensible default.
When it happens
Trigger: Calling setSize(0) or setSize(-1) on a time_series aggregation. Submitting a REST request with `"size": 0`. Defaulting size from a configuration variable that was initialized to zero.
Common situations: Misconfigured index mapping time_series dimension. Tests or tooling that pass zero as a boundary value. Pipelines that compute size dynamically and hit a zero edge case.
Related errors
- buckets must be greater than 0 for [{name}]
- [${name}] is missing : filters parameter
- [separator] must not be null: [${name}]
- [key] must not be null
- [filter] must not be null
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/7981e8e51a8d6633.
Report an issue: GitHub.