# 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`
- **Domain:** elasticsearch
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| elasticsearch 7.17 | active | — | — |
| elasticsearch 8.11 | active | — | — |
| elasticsearch 8.12 | active | — | — |

## Workarounds

1. **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" ] }** (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" ] }
   ```
2. **Temporarily increase index.max_result_window on the specific index: PUT /my_index/_settings { "index.max_result_window": 50000 }** (80% success)
   ```
   Temporarily increase index.max_result_window on the specific index: PUT /my_index/_settings { "index.max_result_window": 50000 }
   ```
3. **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": [ ... ] }** (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": [ ... ] }
   ```

## Dead Ends

- **** — Excessive increase can cause severe memory pressure and OOM on coordinating nodes, especially with deep pagination. (60% fail)
- **** — Scroll is designed for deep pagination but not for random access; it requires maintaining context and doesn't support from+size directly. (70% 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. (80% fail)
