ISSUE SUMMARY
A $nearSphere query with a 2d index, a skip(m), and a limit(n) returns m results less than expected. If m and n are equal, zero results are returned.
USER IMPACT
Query results are incomplete or empty.
WORKAROUNDS
Replace the original value used in limit with the sum of the values used in limit + skip. For example, if using .skip(5).limit(4), specify .skip(5).limit(9) instead.
AFFECTED VERSIONS
MongoDB 2.6 production releases up to 2.6.3 are affected by this issue.
FIX VERSION
The fix is included in the 2.6.4 production release.
RESOLUTION DETAILS
When calculating how many documents to return, add the number of documents previously skipped.
Original description
A $nearSphere query with a 2d index, a skip, and a limit returns one less result than expected. If the limit is 1, then zero results are returned.
Same thing happens if the limit is negative. Not observed with 2dsphere index.
Discovered by Stefan Wójcik while adding geo tests to PyMongo.
- is duplicated by
-
SERVER-14329 2d queries with skip and limit don't behave as expected
- Closed
-
SERVER-14493 mongodb 2.6.3 when use geosearch ,skip() function return unexpected data
- Closed
- related to
-
SERVER-14515 Remove default limit from geoNear operations
- Closed