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

geo query with explicit skip and no explicit limit returns no results

    XMLWordPrintable

    Details

    • Type: Question
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Geo
    • Labels:
      None

      Description

      There is a default limit of 100 results for a geo query. But when a skip or limit is supplied skip + limit results are returned. When skip is supplied but limit is not supplied, a limit of 0 is used and no results are returned.

      > c.ensureIndex( { a:'2d' } )
      > c.save( { a:[ 0, 0 ] } )
      > c.save( { a:[ 0, 0 ] } )
      > c.find( { a:{ $near:[ 0, 0 ] } } )
      { "_id" : ObjectId("4f6d0ac3da35890a46b4b213"), "a" : [ 0, 0 ] }
      { "_id" : ObjectId("4f6d0ac4da35890a46b4b214"), "a" : [ 0, 0 ] }
      > c.find( { a:{ $near:[ 0, 0 ] } } ).skip( 1 ).limit( 1 )
      { "_id" : ObjectId("4f6d0ac4da35890a46b4b214"), "a" : [ 0, 0 ] }
      > c.find( { a:{ $near:[ 0, 0 ] } } ).skip( 1 )
      >

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: