Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-92843

Hidden 2d Indexes used by the Query Planner

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 8.1.0-rc0
    • Affects Version/s: 7.0.9, 7.0.12
    • Component/s: None
    • Query Integration
    • Fully Compatible
    • ALL
    • v8.0, v7.0, v6.0, v5.0
    • Hide
      // Create two 2d indexes on the same field
      db.data.createIndex({ coordinates: "2d" })
      db.data.createIndex({ coordinates: "2d", active: 1 })
      
      // Hide one of the indexes
      db.data.hideIndex({ coordinates: "2d" }) 
      
      // Try to use $geoNear in an aggregation pipeline:
      db.data.aggregate([
        {
          '$geoNear': {
            near: [ 39.7957833, 64.4077002 ],
            distanceField: 'distance',
            maxDistance: 20000
          }
        }
      ])
      
      > MongoServerError[IndexNotFound]: There is more than one 2d index on admin.data; unsure which to use for $geoNear
      Show
      // Create two 2d indexes on the same field db.data.createIndex({ coordinates: "2d" }) db.data.createIndex({ coordinates: "2d" , active: 1 }) // Hide one of the indexes db.data.hideIndex({ coordinates: "2d" })  // Try to use $geoNear in an aggregation pipeline: db.data.aggregate([   {     '$geoNear' : {       near: [ 39.7957833, 64.4077002 ],       distanceField: 'distance' ,       maxDistance: 20000     }   } ]) > MongoServerError[IndexNotFound]: There is more than one 2d index on admin.data; unsure which to use for $geoNear

      Hidden indexes are supposed to be hidden from the query planner, however when there are 2 2d indexes with one hidden, the query planner fails with: "There is more than one 2d index"

            Assignee:
            will.buerger@mongodb.com Will Buerger
            Reporter:
            elie.yaacoub@mongodb.com Elie Yaacoub
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: