{
  "id": "mongodb/geo-2dsphere-index-missing",
  "signature": "MongoServerError: Can't find index: { \"geometry\" : \"2dsphere\" } for namespace test.places",
  "signature_zh": "MongoServerError: 找不到索引：{ \"geometry\" : \"2dsphere\" } 在命名空间 test.places 中",
  "regex": "Can't find index: \\{ \"([^\"]+)\" : \"2dsphere\" \\}",
  "domain": "mongodb",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "A geospatial query or operation requires a 2dsphere index on the geometry field, but the index does not exist or is incorrectly defined.",
  "root_cause_type": "generic",
  "root_cause_zh": "地理空间查询或操作需要在 geometry 字段上存在 2dsphere 索引，但该索引不存在或定义不正确。",
  "versions": [
    {
      "version": "mongodb-3.6",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "mongodb-4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "mongodb-4.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "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": "2d index only supports legacy coordinate pairs, not GeoJSON objects like 'Point' or 'Polygon'.",
      "fail_rate": 0.3,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This does not create the required index; the query still fails.",
      "fail_rate": 0.1,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The index must be on the exact field used in the query's $near or $geoWithin.",
      "fail_rate": 0.25,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Create a 2dsphere index on the geometry field: `db.places.createIndex({geometry:'2dsphere'})`. Ensure the field contains valid GeoJSON objects.",
      "success_rate": 0.95,
      "how": "Create a 2dsphere index on the geometry field: `db.places.createIndex({geometry:'2dsphere'})`. Ensure the field contains valid GeoJSON objects.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the field name is wrong, update the query to use an existing 2dsphere index. Check existing indexes with `db.places.getIndexes()` and adjust the query field accordingly.",
      "success_rate": 0.85,
      "how": "If the field name is wrong, update the query to use an existing 2dsphere index. Check existing indexes with `db.places.getIndexes()` and adjust the query field accordingly.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the data is legacy coordinate pairs, convert them to GeoJSON format using an aggregation pipeline with $addFields and $project, then create the 2dsphere index. Example: `db.places.aggregate([{$addFields:{geometry:{type:'Point',coordinates:['$lon','$lat']}}},{$out:'places'}]); db.places.createIndex({geometry:'2dsphere'})`",
      "success_rate": 0.8,
      "how": "If the data is legacy coordinate pairs, convert them to GeoJSON format using an aggregation pipeline with $addFields and $project, then create the 2dsphere index. Example: `db.places.aggregate([{$addFields:{geometry:{type:'Point',coordinates:['$lon','$lat']}}},{$out:'places'}]); db.places.createIndex({geometry:'2dsphere'})`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Create a 2dsphere index on the geometry field: `db.places.createIndex({geometry:'2dsphere'})`. Ensure the field contains valid GeoJSON objects.",
    "If the field name is wrong, update the query to use an existing 2dsphere index. Check existing indexes with `db.places.getIndexes()` and adjust the query field accordingly.",
    "If the data is legacy coordinate pairs, convert them to GeoJSON format using an aggregation pipeline with $addFields and $project, then create the 2dsphere index. Example: `db.places.aggregate([{$addFields:{geometry:{type:'Point',coordinates:['$lon','$lat']}}},{$out:'places'}]); db.places.createIndex({geometry:'2dsphere'})`"
  ],
  "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": "17067",
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-07-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}