Browse Source
This commit switches from simple collection.count(), operating on potentially false collection statistic, to countDocuments() using an aggregation for accurate results. The transition required query modifications at some points because $match does not support $near and $nearSphere but require $geoWithin along with $center or $centerSphere which does not support $minDistance (see https://jira.mongodb.org/browse/SERVER-37043). $geoWithin further more does not sort results by distance, but this fact can be ignored when just counting matches. Examples: { location : { $near : [-73.99171, 40.738868], $maxDistance : 1.1 } } { location : { $geoWithin : { $center: [ [-73.99171, 40.738868], 1.1] } } } { location : { $near : [-73.99171, 40.738868], $minDistance : 0.1, $maxDistance : 1.1 } } {$and :[ { $nor :[ { location :{ $geoWithin :{ $center :[ [-73.99171, 40.738868 ], 0.01] } } } ]}, { location :{ $geoWithin :{ $center :[ [-73.99171, 40.738868 ], 1.1] } } } ] } Original pull request: #604.pull/802/head
13 changed files with 243 additions and 69 deletions
Loading…
Reference in new issue