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

elemMatch in GeoNear query doesn't support indexes

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.2.3
    • Component/s: Aggregation Framework
    • Labels:
      None
    • ALL

      I use this aggregation for my collection

      {
           "$geoNear": {
               "near": {
                  "type": "Point",
                  "coordinates": [ 38.975313, 45.03547 ],
              },
              "distanceField": "origin.distance",
              "spherical": true,
              "query": {
                  "trip": {
                      "$elemMatch": {
                          "point.pre": true,
                          "point.departure": \{ "$gt": new Date() }
                      }
                  }
              }
          }
       }
      

      and this indexes:

      db.getCollection('sp_trips').createIndex({
          "trip.point" : "2dsphere",
          "trip.point.pre": 1,
          "trip.point.departure": 1
      })
      

      It seems that indexes doesn't work.

       

      For testing I created new indexes

      db.getCollection('sp_trips').createIndex({
          "trip.point.pre": 1,
          "trip.point.departure": 1
      })

      and launch command

      db.getCollection('sp_trips').find({
          "trip": {
              "$elemMatch": {
                  "point.pre": true,
                  "point.departure": \{ "$lt": new Date() }
              }
          }
      }).count()

      This works fine. But If I use elemMatch inside geoNear indexes doesn't work.

            Assignee:
            dmitry.agranat@mongodb.com Dmitry Agranat
            Reporter:
            verrasmal@gmail.com Dennis Smal'
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: