elasticsearch
resource_error
ai_generated
true
SearchContextTooLargeException: 搜索上下文大小超出限制
SearchContextTooLargeException: search context size exceeds limit
ID: elasticsearch/search-context-too-large
78%修复率
82%置信度
1证据数
2024-03-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| elasticsearch 8.11 | active | — | — | — |
| elasticsearch 8.12 | active | — | — | — |
| elasticsearch 7.17 | active | — | — | — |
| opensearch 2.10 | active | — | — | — |
根因分析
搜索请求尝试加载过多文档或字段到内存,超出搜索上下文内存限制。
English
The search request tries to load too many documents or fields into memory, exceeding the search context memory limit.
官方文档
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-settings.html#search-settings-max-search-context-size解决方案
-
通过使用较小的from/size或search_after分页来减少搜索请求大小。
-
动态增加搜索上下文大小限制。
-
使用source filtering只返回必要字段。
无效尝试
常见但无效的做法:
-
85% 失败
This setting controls aggregation buckets, not search context memory; no effect on this error.
-
50% 失败
Search context size limit is separate from heap; heap increase may help indirectly but is not the direct fix.
-
70% 失败
Scroll API also creates search contexts; large size worsens the problem.