{
  "id": "mongodb/geo-index-2dsphere-unsupported-type",
  "signature": "MongoServerError: Can't extract geo keys: 2dsphere index requires 'Point', 'MultiPoint', 'LineString', 'MultiLineString', 'Polygon', or 'MultiPolygon' GeoJSON type, but found 'GeometryCollection'",
  "signature_zh": "MongoServerError: 无法提取地理键：2dsphere 索引需要 'Point'、'MultiPoint'、'LineString'、'MultiLineString'、'Polygon' 或 'MultiPolygon' GeoJSON 类型，但找到 'GeometryCollection'",
  "regex": "Can't extract geo keys: 2dsphere index requires .+ but found 'GeometryCollection'",
  "domain": "mongodb",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "A 2dsphere index cannot index a GeoJSON GeometryCollection directly; it must be decomposed into individual geometries.",
  "root_cause_type": "generic",
  "root_cause_zh": "2dsphere 索引无法直接索引 GeoJSON GeometryCollection；必须将其分解为单独的几何对象。",
  "versions": [
    {
      "version": "MongoDB 4.4",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "MongoDB 5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "MongoDB 6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "MongoDB 7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Creating a sparse index does not bypass the type check; it only skips documents without the field.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using $geoNear with an aggregation pipeline fails with the same error because the index is still applied.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Convert GeometryCollection to an array of individual geometries in the document: update the field to an array like {loc: [{type: 'Point', coordinates: [0,0]}, {type: 'LineString', coordinates: [[1,1],[2,2]]}]} and create a 2dsphere index on the array field.",
      "success_rate": 0.9,
      "how": "Convert GeometryCollection to an array of individual geometries in the document: update the field to an array like {loc: [{type: 'Point', coordinates: [0,0]}, {type: 'LineString', coordinates: [[1,1],[2,2]]}]} and create a 2dsphere index on the array field.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Remove the GeometryCollection document or skip it using a $match stage before the $geoNear stage in aggregation.",
      "success_rate": 0.85,
      "how": "Remove the GeometryCollection document or skip it using a $match stage before the $geoNear stage in aggregation.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "将 GeometryCollection 转换为文档中的单个几何对象数组：将字段更新为数组，如 {loc: [{type: 'Point', coordinates: [0,0]}, {type: 'LineString', coordinates: [[1,1],[2,2]]}]}，并在数组字段上创建 2dsphere 索引。",
    "删除 GeometryCollection 文档，或在聚合中使用 $match 阶段在 $geoNear 阶段之前跳过它。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.mongodb.com/docs/manual/core/2dsphere/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.89,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2023-11-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}