elasticsearch
query_error
ai_generated
true
ElasticsearchException: The aggregation [my_agg] exceeded the max size of [10000]
ID: elasticsearch/aggregation-max-size-exceeded
85%Fix Rate
87%Confidence
1Evidence
2024-09-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| elasticsearch 7.15.0 | active | — | — | — |
| elasticsearch 8.8.0 | active | — | — | — |
| elasticsearch 8.13.0 | active | — | — | — |
Root Cause
A terms aggregation request has a size parameter larger than the default max size limit of 10000.
generic中文
terms聚合请求的size参数超过了默认的最大大小限制10000。
Official Documentation
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.htmlWorkarounds
-
85% success Increase the max size limit dynamically: PUT _cluster/settings { "transient": { "search.max_buckets": 20000 } }
Increase the max size limit dynamically: PUT _cluster/settings { "transient": { "search.max_buckets": 20000 } } -
90% success Reduce the aggregation size to 10000 or lower, and use pagination with composite aggregation for larger datasets.
Reduce the aggregation size to 10000 or lower, and use pagination with composite aggregation for larger datasets.
-
75% success Use a filtered aggregation to narrow down the result set, e.g., add a query filter before the aggregation.
Use a filtered aggregation to narrow down the result set, e.g., add a query filter before the aggregation.
中文步骤
动态增加最大大小限制:PUT _cluster/settings { "transient": { "search.max_buckets": 20000 } }将聚合size减少到10000或更少,并对更大数据集使用composite聚合进行分页。
使用过滤聚合缩小结果集,例如在聚合前添加查询过滤器。
Dead Ends
Common approaches that don't work:
-
60% fail
Size 0 is treated as unlimited, but can cause memory overflow and is deprecated in newer versions.
-
90% fail
The cluster-level max size limit still applies; the error persists unless the limit is raised.
-
40% fail
Composite aggregation has its own limits and may not be suitable for all use cases.