[SERVER-8448] No results with $near and $nearSphere queries using 2dsphere indexes and $maxDistance parameter Created: 04/Feb/13 Updated: 15/Feb/13 Resolved: 07/Feb/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Geo, Querying |
| Affects Version/s: | 2.3.2, 2.4.0-rc0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Jim Dagg | Assignee: | hari.khalsa@10gen.com |
| Resolution: | Done | Votes: | 0 |
| Labels: | query | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 7 Professional |
||
| Backwards Compatibility: | Fully Compatible |
| Operating System: | ALL |
| Steps To Reproduce: | 1) Generate documents with 2dsphere index, including Point, LineString, and Polygon |
| Participants: |
| Description |
|
Per the current documentation for 2dsphere indexes, queries using $near and $nearSphere require a GeoJSON point passed to them, but otherwise work normally. However, $near and $nearSphere queries against a field with a 2dsphere index return no results if a $maxDistance parameter is provided. e.g. }}) db.random.find( {geometry: { $nearSphere: {type:"Point", "coordinates":[-83,40]}, $maxDistance: 10}}) |
| Comments |
| Comment by Jim Dagg [ 05/Feb/13 ] |
|
Via communication with Hari Khalsa on the user forum (https://groups.google.com/forum/?fromgroups=#!topic/mongodb-user/5SecGQnDgUY), I learned that the $maxDistance parameter expects distances in meters, not in radians, when a GeoJSON point is provided to $nearSphere. So this appears to be working as designed. |