[SERVER-11832] Misplaced $maxDistance can work in v2.4, not in v2.5 Created: 22/Nov/13  Updated: 10/Dec/14  Resolved: 05/Dec/13

Status: Closed
Project: Core Server
Component/s: Geo, Querying
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Luke Lovett Assignee: Benety Goh
Resolution: Won't Fix Votes: 0
Labels: 26qa, nqf, query_triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

> db.serverBuildInfo()
{
"version" : "2.4.9-pre-",
"gitVersion" : "38b3b8f7395d6717efd570a62dc1c2c085d1b049",
"sysInfo" : "Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49",
"loaderFlags" : "-fPIC -pthread -rdynamic",
"compilerFlags" : "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -pipe -fno-builtin-memcmp -O3",
"allocator" : "tcmalloc",
"versionArray" : [
2,
4,
9,
-100
],
"javascriptEngine" : "V8",
"bits" : 64,
"debug" : false,
"maxBsonObjectSize" : 16777216,
"ok" : 1
}
and
> db.serverBuildInfo()
{
"version" : "2.5.5-pre-",
"gitVersion" : "4d722953fa6e7f0cd8732601ed7c5c1cb8808bad",
"OpenSSLVersion" : "",
"sysInfo" : "Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49",
"loaderFlags" : "-fPIC -pthread -Wl,-z,now -rdynamic",
"compilerFlags" : "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -pipe -O3 -Wno-unused-function -Wno-deprecated-declarations -fno-builtin-memcmp",
"allocator" : "tcmalloc",
"versionArray" : [
2,
5,
5,
-100
],
"javascriptEngine" : "V8",
"bits" : 64,
"debug" : false,
"maxBsonObjectSize" : 16777216,
"ok" : 1
}


Attachments: File server11832.js    
Issue Links:
Related
related to DRIVERS-147 $maxDistance changes in 2.6 for GeoJSON Closed
related to SERVER-12929 Improve error message for 2dsphere $n... Closed
Backwards Compatibility: Major Change
Operating System: ALL
Steps To Reproduce:

2.5.5-pre-

> db.c.find({loc:{$nearSphere:{$geometry:{type:"Point", coordinates:[20,20]}},$maxDistance:10e100000}})
error: {
	"$err" : "can't parse query (2dsphere): { $nearSphere: { $geometry: { type: \"Point\", coordinates: [ 20.0, 20.0 ] } }, $maxDistance: inf.0 }",
	"code" : 16535
}
> db.c.find({loc:{$near:{$geometry:{type:"Point", coordinates:[20,20]}},$maxDistance:10e100000}})
error: {
	"$err" : "can't parse query (2dsphere): { $near: { $geometry: { type: \"Point\", coordinates: [ 20.0, 20.0 ] } }, $maxDistance: inf.0 }",
	"code" : 16535
}
> db.c.find({loc:{$nearSphere:{$geometry:{type:"Point", coordinates:[20,20]},$maxDistance:10e100000}}})
{ "_id" : ObjectId("528fa99e6ce2fec2710a135a"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
{ "_id" : ObjectId("528fa9b06ce2fec2710a135b"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }
> db.c.find({loc:{$near:{$geometry:{type:"Point", coordinates:[20,20]},$maxDistance:10e100000}}})
{ "_id" : ObjectId("528fa99e6ce2fec2710a135a"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
{ "_id" : ObjectId("528fa9b06ce2fec2710a135b"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }

2.4.9-pre-

> db.c.find({loc:{$nearSphere:{$geometry:{type:"Point", coordinates:[20,20]}},$maxDistance:10e100000}})
{ "_id" : ObjectId("528fa99e5142cd7d1e23d1ba"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
{ "_id" : ObjectId("528fa9b05142cd7d1e23d1bb"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }
> db.c.find({loc:{$near:{$geometry:{type:"Point", coordinates:[20,20]}},$maxDistance:10e100000}})
{ "_id" : ObjectId("528fa99e5142cd7d1e23d1ba"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
{ "_id" : ObjectId("528fa9b05142cd7d1e23d1bb"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }
> db.c.find({loc:{$nearSphere:{$geometry:{type:"Point", coordinates:[20,20]},$maxDistance:10e100000}}})
{ "_id" : ObjectId("528fa99e5142cd7d1e23d1ba"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
{ "_id" : ObjectId("528fa9b05142cd7d1e23d1bb"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }
> db.c.find({loc:{$near:{$geometry:{type:"Point", coordinates:[20,20]},$maxDistance:10e100000}}})
{ "_id" : ObjectId("528fa99e5142cd7d1e23d1ba"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
{ "_id" : ObjectId("528fa9b05142cd7d1e23d1bb"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }

Participants:

 Description   

$near and $geoNear will still work and return documents even if the syntax for $maxDistance is incorrect (i.e., placed outside the $geometry operator's document) in version 2.4 of MongoDB. Version 2.5 throws an error instead.


Generated at Thu Feb 08 03:26:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.