title: MongoDB query: Using Limit together with $near skips few documents
body: <p>I am currently developing an app which gets the specific number of documents from a collection if their location cordinates falls within certain range of distance. I am using a active record library for Codeigniter and the query that is generated is as follows</p>
  
  <pre><code>db.updates.find({locs: { $near: [72.844102008984, 19.130207090604 ], $maxDistance: 5000 },  posted_on : { $lt :1398425538.1942 },}).sort( { posted_on: -1 } ).limit(10).toArray()
  </code></pre>
  
  <p>The problem I am facing is that the above query skips few documents which should actually get pulled. But if I remove the <code>limit(10)</code> from the above query then proper documents gets pulled. </p>
  
  <p>I am not sure, but does using limit() in MongoDB omit few results ? or does it limits to only the closest(nearest) documents?</p>
  
  <p>P.S - The documents skipped using the limit are not always the same &amp; random results are generated</p>