NearQuery - Inconsistent distance returned by MongoDB 2.6 and MongoDB 2.4 [DATAMONGO-906] #1831
Comments
Thomas Darimont commented Hello Titi, thanks for reporting this - is this changed behaviour documented somewhere in the mongodb docs? Cheers, |
Thomas Darimont commented Actually, to me this looks like an inconsistency / bug in mongodb 2.6.0 itself.
|
Thomas Darimont commented I created https://jira.mongodb.org/browse/SERVER-13540 to discuss this with the MongoDB devs |
Thomas Darimont commented Small update: The mongodb server team confirmed this as a bug - waiting for a solution |
Thomas Darimont commented This is fixed in the master of mongodb/mongo Server and backported to the 2.6 branch so it should be available with the next 2.6.x version of mongodb |
Thomas Darimont commented Resolved as Work as Design. This is a MongoDb issue that has already been fixed by the MognoDb team. |
Titi Wangsa opened DATAMONGO-906 and commented
From the MongoDB documentation:
http://docs.mongodb.org/manual/reference/command/geoNear/
this returns consistently returns the distance in meters (mongodb 2.4 and 2.6)
However, the behavior of Spring Data MongoDB is not consistent
NearQuery.java:364
the JSON will be:
instead of
The form:
will return "radian" for MongoDB 2.4
will return "meter" for MongoDB 2.6
whereas this form:
will return "meter" for MongoDB 2.4
will return "meter" for MongoDB 2.6
here are the mongodb commands that I ran to verify this
Problem is, if we simply replace
to
this will break existing MongoDB 2.4 applications
My suggestion is to change it to
AND handle "distanceMultiplier"
to
the only drawback to this is, the default value is inconsistent with MongoDB's default value.
Options:
Option 1. Do nothing.
Impact: Applications what worked with MongoDB 2.4 will get different distance result with MongoDB is upgraded to MongoDB 2.6
Option 2: Alter the code and use "meter" as default.
Impact: Will cause existing applications on MongoDB 2.4 to fail.
Option 3: Alter the code to consistently return "radian" no matter the version.
Impact: Existing applications on MongoDB 2.4 will work just fine.
MongoDB 2.6 users might feel weird as the "distance" without specifying the "distanceMultiplier" is not what they might initially expect.
Affects: 1.4.1 (Codd SR1)
Backported to: 1.3.5 (Babbage SR4)
The text was updated successfully, but these errors were encountered: