[SERVER-2342] $within: {$center} vs. $near and $maxDistance Created: 10/Jan/11 Updated: 12/Jul/16 Resolved: 27/Jan/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 1.7.4 |
| Fix Version/s: | 1.7.6 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Kyle Banker | Assignee: | Mathias Stearn |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Operating System: | ALL | ||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
Shouldn't these two types of queries return the same results? They don't always. Why not? Attached is a zip code database you can use to test. Here are two queries: > use geo , $maxDistance: 0.01}}).count() > db.zips.find({loc: {$within: {$center: [ [40.752315, -73.977842], 0.01 ] }}}).count() But... > db.zips.find({'loc': {$near: {x: 40.752315, y: -73.977842}, $maxDistance: 0.011 }}).count() > db.zips.find({loc: {$within: {$center: [ [40.752315, -73.977842], 0.011 ] }}}).count() If they're supposed to return the same results, why have them both? If they're not, what's sort of meaningful distinction is there between them? |
| Comments |
| Comment by auto [ 27/Jan/11 ] |
|
Author: {u'login': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}Message: fix $near with $maxDistance |
| Comment by Scott Hernandez (Inactive) [ 10/Jan/11 ] |
|
Isn't the difference here whether the $maxDistance value is inclusive or exclusive? In the $near case it is not, and for $whithin it is. This is how I understood things to work. Is there something more going on? |
| Comment by Mathias Stearn [ 10/Jan/11 ] |
|
I think these are related. The handling of $maxDistance is off. |