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

Hints are allowed on special indexes like 2d and text but lead to incorrect results

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Blocker - P1 Blocker - P1
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • ALL

      We should do one of A) disallow these hints, B) ignore the hints, C) (somehow) make them produce the correct query results. I strongly prefer option A or B with a slight preference for A over B.

      > db.foo.insert({a:1})
      WriteResult({ "nInserted" : 1 })
      > db.foo.createIndex({x: '2d'})
      {
      	"numIndexesBefore" : 1,
      	"numIndexesAfter" : 2,
      	"createdCollectionAutomatically" : false,
      	"ok" : 1
      }
      > db.foo.createIndex({x: '2dsphere'})
      {
      	"numIndexesBefore" : 2,
      	"numIndexesAfter" : 3,
      	"createdCollectionAutomatically" : false,
      	"ok" : 1
      }
      > db.foo.createIndex({x: 'text'})
      {
      	"numIndexesBefore" : 3,
      	"numIndexesAfter" : 4,
      	"createdCollectionAutomatically" : false,
      	"ok" : 1
      }
      
      // finds a doc
      > db.foo.find({a:1})
      { "_id" : ObjectId("61d1143d15ce86cd9a31d385"), "a" : 1 }
      
      // None of these find the doc
      > db.foo.find({a:1}).hint({x: '2d'})
      > db.foo.find({a:1}).hint({x: '2dsphere'})
      > db.foo.find({a:1}).hint('x_text')
      >
      

      I didn't test with "somewhat special" indexes like partial indexes or filtered indexes, but they may have the same issue.

            Assignee:
            kateryna.kamenieva@mongodb.com Katya Kamenieva
            Reporter:
            mathias@mongodb.com Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: