Description
In 2.2.0 performing a find or $near on a geographic index with a secondary field to the geospatial will cause any exact locations queries to return nothing and $near will not have the exact match included in the results.
This only effects indexes with a second field in addition to the geographical field.
This issue doesn't occur under 2.0.7.
Example
Document:
{
|
"_id" : ObjectId("4f55fd08cee147f736000000"),
|
"city" : "A",
|
"lon_lat" : [
|
1.48736,
|
42.55327
|
],
|
"population" : 100,
|
}
|
{
|
"_id" : ObjectId("4f5606c4cee147f7362b8f59"),
|
"city" : "B",
|
"lon_lat" : [
|
-71.34895,
|
42.46037
|
],
|
"population" : 1000,
|
}
|
Index:
{ "v" : 1, "key" : { "lon_lat" : "2d", "population" : -1 }, "ns" : "test.location_categories", "min" : -180, "max" : 181, "background" : true, "name" : "lon_lat_2d_population_-1" }
|
Query:
db.location_categories.find({lon_lat : {$near : [-71.34895, 42.46037] } });
|
Query 2:
db.location_categories.find({lon_lat : [-71.34895, 42.46037] })
|
Given the query we should match city B as it is at the co-ordinates, but is not being returned.