{
  "id": "mongodb/geo-index-coordinates-invalid",
  "signature": "MongoServerError: Can't extract geo keys: invalid coordinate value: latitude out of range [-90, 90]",
  "signature_zh": "MongoServerError: 无法提取地理键：无效的坐标值：纬度超出范围 [-90, 90]",
  "regex": "Can't extract geo keys: invalid coordinate value: latitude out of range \\[-90, 90\\]",
  "domain": "mongodb",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "A document with a 2dsphere index contains a coordinate with latitude outside the valid range of -90 to 90 degrees.",
  "root_cause_type": "generic",
  "root_cause_zh": "具有 2dsphere 索引的文档包含一个纬度超出 -90 到 90 度有效范围的坐标。",
  "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The index rebuilds from the same invalid data, causing the same error.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The validation is part of the geospatial index specification and is version-independent.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "MongoDB does not support custom validation for geospatial index constraints.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Query for documents with invalid coordinates using $geoNear with a large radius to identify them, then update or delete: db.places.find({ loc: { $geoWithin: { $centerSphere: [[0, 0], 3.14159] } } })",
      "success_rate": 0.7,
      "how": "Query for documents with invalid coordinates using $geoNear with a large radius to identify them, then update or delete: db.places.find({ loc: { $geoWithin: { $centerSphere: [[0, 0], 3.14159] } } })",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use an aggregation pipeline to find documents where loc.coordinates[1] is outside [-90, 90] and fix them: db.places.aggregate([ { $match: { $expr: { $or: [ { $lt: [ { $arrayElemAt: [\"$loc.coordinates\", 1] }, -90 ] }, { $gt: [ { $arrayElemAt: [\"$loc.coordinates\", 1] }, 90 ] } ] } } } ])",
      "success_rate": 0.85,
      "how": "Use an aggregation pipeline to find documents where loc.coordinates[1] is outside [-90, 90] and fix them: db.places.aggregate([ { $match: { $expr: { $or: [ { $lt: [ { $arrayElemAt: [\"$loc.coordinates\", 1] }, -90 ] }, { $gt: [ { $arrayElemAt: [\"$loc.coordinates\", 1] }, 90 ] } ] } } } ])",
      "condition": "",
      "sources": []
    },
    {
      "action": "Drop the 2dsphere index, bulk update all documents to clamp coordinates to valid ranges, then recreate the index: db.places.dropIndex(\"loc_2dsphere\"); db.places.updateMany({}, [{ $set: { \"loc.coordinates.1\": { $max: [ { $min: [ \"$loc.coordinates.1\", 90 ] }, -90 ] } } } ]); db.places.createIndex({ loc: \"2dsphere\" })",
      "success_rate": 0.9,
      "how": "Drop the 2dsphere index, bulk update all documents to clamp coordinates to valid ranges, then recreate the index: db.places.dropIndex(\"loc_2dsphere\"); db.places.updateMany({}, [{ $set: { \"loc.coordinates.1\": { $max: [ { $min: [ \"$loc.coordinates.1\", 90 ] }, -90 ] } } } ]); db.places.createIndex({ loc: \"2dsphere\" })",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Query for documents with invalid coordinates using $geoNear with a large radius to identify them, then update or delete: db.places.find({ loc: { $geoWithin: { $centerSphere: [[0, 0], 3.14159] } } })",
    "Use an aggregation pipeline to find documents where loc.coordinates[1] is outside [-90, 90] and fix them: db.places.aggregate([ { $match: { $expr: { $or: [ { $lt: [ { $arrayElemAt: [\"$loc.coordinates\", 1] }, -90 ] }, { $gt: [ { $arrayElemAt: [\"$loc.coordinates\", 1] }, 90 ] } ] } } } ])",
    "Drop the 2dsphere index, bulk update all documents to clamp coordinates to valid ranges, then recreate the index: db.places.dropIndex(\"loc_2dsphere\"); db.places.updateMany({}, [{ $set: { \"loc.coordinates.1\": { $max: [ { $min: [ \"$loc.coordinates.1\", 90 ] }, -90 ] } } } ]); db.places.createIndex({ loc: \"2dsphere\" })"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.mongodb.com/docs/manual/geospatial-queries/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-04-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}