{
  "id": "elasticsearch/search-phase-execution-timeout",
  "signature": "SearchPhaseExecutionException: all shards failed: [search_phase_execution_exception] Reason: Timed out after [30000ms] while waiting for search results",
  "signature_zh": "搜索阶段执行异常：所有分片失败：[search_phase_execution_exception] 原因：等待搜索结果超时 [30000ms]",
  "regex": "SearchPhaseExecutionException: all shards failed: \\[search_phase_execution_exception\\] Reason: Timed out after \\[\\d+ms\\] while waiting for search results",
  "domain": "elasticsearch",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The search request timed out because one or more shards took longer than the configured timeout to respond, often due to slow queries or resource contention.",
  "root_cause_type": "generic",
  "root_cause_zh": "搜索请求超时，因为一个或多个分片响应时间超过了配置的超时时间，通常是由于慢查询或资源争用。",
  "versions": [
    {
      "version": "elasticsearch 7.17",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "elasticsearch 8.10",
      "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This only delays the failure; slow queries still consume resources and may eventually cause cluster instability.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This changes the search semantics and returns inaccurate results, breaking application functionality.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Restarting does not fix the underlying slow query or resource issue; the timeout will recur after the cluster recovers.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Increase the search timeout for specific requests: POST /my_index/_search { \"timeout\": \"60s\", \"query\": { \"match\": { \"field\": \"value\" } } }",
      "success_rate": 0.8,
      "how": "Increase the search timeout for specific requests: POST /my_index/_search { \"timeout\": \"60s\", \"query\": { \"match\": { \"field\": \"value\" } } }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Optimize the query by adding index filters or reducing aggregation complexity: use 'filter' context instead of 'query' for non-scoring filters, and limit 'size' and 'aggs'.",
      "success_rate": 0.85,
      "how": "Optimize the query by adding index filters or reducing aggregation complexity: use 'filter' context instead of 'query' for non-scoring filters, and limit 'size' and 'aggs'.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use async search for long-running queries: POST /my_index/_async_search { \"size\": 0, \"query\": { \"match_all\": {} }, \"aggs\": { \"my_agg\": { \"terms\": { \"field\": \"field\", \"size\": 10000 } } }, \"wait_for_completion_timeout\": \"10s\" }",
      "success_rate": 0.9,
      "how": "Use async search for long-running queries: POST /my_index/_async_search { \"size\": 0, \"query\": { \"match_all\": {} }, \"aggs\": { \"my_agg\": { \"terms\": { \"field\": \"field\", \"size\": 10000 } } }, \"wait_for_completion_timeout\": \"10s\" }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "增加特定请求的搜索超时时间：POST /my_index/_search { \"timeout\": \"60s\", \"query\": { \"match\": { \"field\": \"value\" } } }",
    "通过添加索引过滤器或减少聚合复杂度来优化查询：对非评分过滤器使用 'filter' 上下文而非 'query'，并限制 'size' 和 'aggs'。",
    "对长时间运行的查询使用异步搜索：POST /my_index/_async_search { \"size\": 0, \"query\": { \"match_all\": {} }, \"aggs\": { \"my_agg\": { \"terms\": { \"field\": \"field\", \"size\": 10000 } } }, \"wait_for_completion_timeout\": \"10s\" }"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/search-timeout.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-03-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}