elasticsearch resource_error ai_generated true

SearchContextTooLargeException: 搜索上下文大小超出限制

SearchContextTooLargeException: search context size exceeds limit

ID: elasticsearch/search-context-too-large

其他格式: JSON · Markdown 中文 · English
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.

generic

官方文档

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-settings.html#search-settings-max-search-context-size

解决方案

  1. 通过使用较小的from/size或search_after分页来减少搜索请求大小。
  2. 动态增加搜索上下文大小限制。
  3. 使用source filtering只返回必要字段。

无效尝试

常见但无效的做法:

  1. 85% 失败

    This setting controls aggregation buckets, not search context memory; no effect on this error.

  2. 50% 失败

    Search context size limit is separate from heap; heap increase may help indirectly but is not the direct fix.

  3. 70% 失败

    Scroll API also creates search contexts; large size worsens the problem.