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

Compound index with datetime and geospatial fields doesn't work

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.9
    • Component/s: Index Maintenance
    • None
    • ALL

      I've created a compound index:

      db.lightningStrikes.createIndex({ datetime: -1, location: "2dsphere" })
      

      But when I run the query below the MongoDB doesn't consider the index, making a COLLSCAN.

      db.lightningStrikes.find({ datetime: { $gte: new Date('2017-10-15T00:00:00Z') } }).explain(true).executionStats
      

      Ps. When I create a compound index by datetime and another type of field it works (searching by index), as below:

      db.lightningStrikes.createIndex({ datetime: -1, source: 1 })
      

      I've seen in the documentation and I haven't found any reason for it.
      https://docs.mongodb.com/manual/core/2dsphere/#create-a-compound-index-with-2dsphere-index-key

            Assignee:
            mark.agarunov Mark Agarunov
            Reporter:
            michaelfdias Michael Felix Dias
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: