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

Option "query" of pipeline "$geoNear" can not use the indexes

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Query 2018-08-13

      I have an aggregation to find players have score near someone's score:

       

      db.collection.aggregate([

         {

            $geoNear: {
               limit: 10,
               near: [0, 0],
               distanceField: "range",
               query: {playerId: {$ne: ObjectId("5b3d905d0e79f323249ff14e")}, score: {$gt: 0}, seasonId: ObjectId("5b447af4d4e83558ee3b30d3")}
            }

         }

      ]);

       

      I created indexes for playerId field and seasonId field. When I do a normal find query with playerId or seasonId, I use the indexes of them. But when I run the above aggregation query, the option query of "$geoNear" can not use the indexes.

       

      So, please improve this feature, thanks so much.

            Assignee:
            kyle.suarez@mongodb.com Kyle Suarez
            Reporter:
            Rubilk Trung Le [X]
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: