{
  "id": "elasticsearch/search-context-too-large",
  "signature": "SearchContextTooLargeException: search context size exceeds limit",
  "signature_zh": "SearchContextTooLargeException: 搜索上下文大小超出限制",
  "regex": "search context size exceeds limit",
  "domain": "elasticsearch",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "The search request tries to load too many documents or fields into memory, exceeding the search context memory limit.",
  "root_cause_type": "generic",
  "root_cause_zh": "搜索请求尝试加载过多文档或字段到内存，超出搜索上下文内存限制。",
  "versions": [
    {
      "version": "elasticsearch 8.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "elasticsearch 8.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "elasticsearch 7.17",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "opensearch 2.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This setting controls aggregation buckets, not search context memory; no effect on this error.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Search context size limit is separate from heap; heap increase may help indirectly but is not the direct fix.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Scroll API also creates search contexts; large size worsens the problem.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Reduce the search request size by using smaller from/size or using search_after for pagination. Example: POST /my_index/_search { \"size\": 100, \"search_after\": [12345, \"abc\"] }",
      "success_rate": 0.85,
      "how": "Reduce the search request size by using smaller from/size or using search_after for pagination. Example: POST /my_index/_search { \"size\": 100, \"search_after\": [12345, \"abc\"] }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Increase the search context size limit dynamically: PUT _cluster/settings { \"persistent\": { \"search.max_search_context_size\": \"10mb\" } }",
      "success_rate": 0.75,
      "how": "Increase the search context size limit dynamically: PUT _cluster/settings { \"persistent\": { \"search.max_search_context_size\": \"10mb\" } }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use source filtering to return only needed fields: POST /my_index/_search { \"_source\": [\"field1\", \"field2\"], \"size\": 1000 }",
      "success_rate": 0.8,
      "how": "Use source filtering to return only needed fields: POST /my_index/_search { \"_source\": [\"field1\", \"field2\"], \"size\": 1000 }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "通过使用较小的from/size或search_after分页来减少搜索请求大小。",
    "动态增加搜索上下文大小限制。",
    "使用source filtering只返回必要字段。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/search-settings.html#search-settings-max-search-context-size",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.78,
  "resolvable": "true",
  "first_seen": "2024-03-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}