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

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

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.3
    • Component/s: Geo
    • None
    • ALL
    • 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.

      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)

            Assignee:
            siyuan.zhou@mongodb.com Siyuan Zhou
            Reporter:
            doronpagot@gmail.com Doron Pagot
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: