elasticsearch
runtime_error
ai_generated
true
QueryPhaseExecutionException: Result window is too large, from + size must be less than or equal to: [10000] but was [50000]
ID: elasticsearch/max-clause-count-exceeded
85%Fix Rate
88%Confidence
1Evidence
2024-03-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| elasticsearch 7.17 | active | — | — | — |
| elasticsearch 8.11 | active | — | — | — |
| elasticsearch 8.12 | active | — | — | — |
Root Cause
The combination of 'from' and 'size' parameters in a search request exceeds the 'index.max_result_window' setting, causing query execution to fail.
generic中文
搜索请求中 'from' 和 'size' 参数的组合超过了 'index.max_result_window' 设置,导致查询执行失败。
Official Documentation
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.htmlWorkarounds
-
90% success Use search_after with sort to implement cursor-based pagination, avoiding from+size limits. Example: POST /my_index/_search { "size": 10, "sort": [ { "date": "asc" } ], "search_after": [ "2024-01-01T00:00:00" ] }
Use search_after with sort to implement cursor-based pagination, avoiding from+size limits. Example: POST /my_index/_search { "size": 10, "sort": [ { "date": "asc" } ], "search_after": [ "2024-01-01T00:00:00" ] } -
80% success Temporarily increase index.max_result_window on the specific index: PUT /my_index/_settings { "index.max_result_window": 50000 }
Temporarily increase index.max_result_window on the specific index: PUT /my_index/_settings { "index.max_result_window": 50000 } -
95% success Use point-in-time (PIT) with search_after for stable deep pagination in ES 7.10+: POST /my_index/_pit?keep_alive=1m then POST /_search { "pit": { "id": "...", "keep_alive": "1m" }, "size": 100, "sort": [ { "_shard_doc": "asc" } ], "search_after": [ ... ] }
Use point-in-time (PIT) with search_after for stable deep pagination in ES 7.10+: POST /my_index/_pit?keep_alive=1m then POST /_search { "pit": { "id": "...", "keep_alive": "1m" }, "size": 100, "sort": [ { "_shard_doc": "asc" } ], "search_after": [ ... ] }
中文步骤
使用 search_after 配合排序实现基于游标的分页,避免 from+size 限制。示例:POST /my_index/_search { "size": 10, "sort": [ { "date": "asc" } ], "search_after": [ "2024-01-01T00:00:00" ] }临时提高特定索引的 index.max_result_window:PUT /my_index/_settings { "index.max_result_window": 50000 }在 ES 7.10+ 中使用 point-in-time (PIT) 和 search_after 实现稳定的深度分页:POST /my_index/_pit?keep_alive=1m 然后 POST /_search { "pit": { "id": "...", "keep_alive": "1m" }, "size": 100, "sort": [ { "_shard_doc": "asc" } ], "search_after": [ ... ] }
Dead Ends
Common approaches that don't work:
-
60% fail
Excessive increase can cause severe memory pressure and OOM on coordinating nodes, especially with deep pagination.
-
70% fail
Scroll is designed for deep pagination but not for random access; it requires maintaining context and doesn't support from+size directly.
-
80% fail
This suppresses total hit count but doesn't resolve the from+size limit; the error persists if from+size still exceeds max_result_window.