[DOCS-1828] Comment on: "manual/reference/operator/near.txt" Created: 19/Aug/13  Updated: 11/Jan/17  Resolved: 27/Jul/16

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: 01112017-cleanup

Type: Improvement Priority: Minor - P4
Reporter: Jake Orr Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mongo v2.4.4 hosted by MongoLab

Location: http://docs.mongodb.org/manual/reference/operator/near/
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/536.30.1 (KHTML, like Gecko) Version/6.0.5 Safari/536.30.1
Referrer: http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CC4QFjAA&url=http%3A%2F%2Fdocs.mongodb.org%2Fmanual%2Freference%2Foperator%2Fnear&ei=1lMSUvSsDoqMyQHlhYAw&usg=AFQjCNE0k4sAyfIWH48iWxL8Ci03R2gsKg&bvm=bv.50768961,d.aWc
Screen Resolution: 1280 x 800
repo: docs
source: reference/operator/near


Participants:
Days since reply: 7 years, 29 weeks ago

 Description   

Hi,

I've been doing some testing to make sure queries are working as expected when I migrate our dataset over to GeoJSON coordinates and a 2dsphere index. I've noticed what I think is an error in the documentation for $near. It regards the units for $maxDistance.

You mention that $maxDistance should be specified in radians for legacy coordinate pairs. I have been testing on a collection where documents have both legacy and GeoJSON coodinate pairs in separate fields. In this test environment I am running both a 2d and 2dsphere index (just for testing, as it works but I realize it is undocumented and could have unexpected consequences). I am comparing queries using the same centre point and converted radians->metres $maxDistance.

Centre: 37.755244,-122.444

I first followed the documentation and used a $maxDistance of 1407m for the 2dsphere/GeoJSON query and 0.00022 rad (calc: 1407/6371000) for the legacy coodinate/2d query. The 2dsphere query returns 10 documents, the 2d query returns none. Next, instead of radians I tried using decimal degrees. A distance of 1407 m works out to about 0.016 degrees for the above centre location. This time the 2d query returns the same results as the 2dsphere query.

I think the documentation should say "If you query for legacy coordinate pairs, specify $maxDistance in decimal degrees." As I understand it, that is not the same thing as radians. I think that this change could really help people in the future as I've spent a bunch of time figuring it out.

If I've missed something or just don't get it, I'd love to hear about it! Also if you have any questions, please let me know.

Cheers,
Jake
jake@cityseed.com



 Comments   
Comment by Emily Hall [ 27/Jul/16 ]

Closed by Emily Hall for Housekeeping on 7/27/16.
Please create a new ticket if for prioritization.

Thank you!

Generated at Thu Feb 08 07:42:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.