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

2d queries with skip and limit don't behave as expected

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 2.6.3
    • Fix Version/s: None
    • Component/s: Geo
    • Labels:
      None
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      to reproduce (in mongo client):

          db.test.drop();
          db.test.ensureIndex({point: "2d"});
          for (var i = 0; i < 200; ++i) { 
            db.test.insert({point:[1,2]});
          }
          db.test.insert({point:[1,2.01]});
          db.test.find({point: {$nearSphere: [1,2]}}).skip(200).limit(201);

      returns:

      > { "_id" : ObjectId("53a476c6c83c83ebdd121038"), "point" : [ 1, 2.01 ] }

      when you

          db.test.find({point: {$nearSphere: [1,2]}}).skip(200).limit(1);

      there's nothing.

      Show
      to reproduce (in mongo client): db.test.drop(); db.test.ensureIndex({point: "2d"}); for (var i = 0; i < 200; ++i) { db.test.insert({point:[1,2]}); } db.test.insert({point:[1,2.01]}); db.test.find({point: {$nearSphere: [1,2]}}).skip(200).limit(201); returns: > { "_id" : ObjectId("53a476c6c83c83ebdd121038"), "point" : [ 1, 2.01 ] } when you db.test.find({point: {$nearSphere: [1,2]}}).skip(200).limit(1); there's nothing.

      Description

      when you skip '2d' geo queries, the limit starts from the start and not from the skip. for example, skip 100, limit 1 will always return nothing, but skip 100, limit 101 will return a single value (if exists)

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: