{
  "id": "elasticsearch/field-cache-too-large",
  "signature": "OutOfMemoryError: Java heap space: failed to allocate field data for field [user.id]",
  "signature_zh": "内存溢出：Java堆空间：无法为字段[user.id]分配字段数据",
  "regex": "OutOfMemoryError: Java heap space: failed to allocate field data for field \\[.*\\]",
  "domain": "elasticsearch",
  "category": "system_error",
  "subcategory": null,
  "root_cause": "The fielddata cache for a high-cardinality field (e.g., user.id) consumes too much heap memory, triggering an OutOfMemoryError.",
  "root_cause_type": "generic",
  "root_cause_zh": "高基数字段（例如user.id）的字段数据缓存消耗过多堆内存，触发内存溢出错误。",
  "versions": [
    {
      "version": "7.17.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.10.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.12.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Larger heap may postpone OOM but fielddata can grow unbounded; eventually OOM recurs",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Disabling fielddata breaks aggregations and sorting on that field; queries that depend on it will fail",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Set a fielddata circuit breaker limit: PUT _cluster/settings { \"persistent\": { \"indices.breaker.fielddata.limit\": \"30%\" } } and also set fielddata cache size: PUT _cluster/settings { \"persistent\": { \"indices.fielddata.cache.size\": \"20%\" } }",
      "success_rate": 0.85,
      "how": "Set a fielddata circuit breaker limit: PUT _cluster/settings { \"persistent\": { \"indices.breaker.fielddata.limit\": \"30%\" } } and also set fielddata cache size: PUT _cluster/settings { \"persistent\": { \"indices.fielddata.cache.size\": \"20%\" } }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use doc_values instead of fielddata by reindexing the field with doc_values: true; for keyword fields, doc_values is enabled by default, so avoid aggregating on text fields without doc_values",
      "success_rate": 0.9,
      "how": "Use doc_values instead of fielddata by reindexing the field with doc_values: true; for keyword fields, doc_values is enabled by default, so avoid aggregating on text fields without doc_values",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "设置字段数据断路器限制：PUT _cluster/settings { \"persistent\": { \"indices.breaker.fielddata.limit\": \"30%\" } }，同时设置字段数据缓存大小：PUT _cluster/settings { \"persistent\": { \"indices.fielddata.cache.size\": \"20%\" } }",
    "使用doc_values代替fielddata：重新索引字段并启用doc_values: true；对于keyword字段，doc_values默认启用，因此避免在没有doc_values的text字段上进行聚合"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.72,
  "resolvable": "partial",
  "first_seen": "2023-09-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}