-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.4.3
-
Component/s: Geo, Index Maintenance
-
None
-
Environment:Windows 7 x64
-
ALL
-
When performing a $near or geoNear query on GeoJSON data indexed with a 2dsphere index, the query appears to miss data. This may be an issue with the 2dsphere index, as reindexing changes the number of data elements returned for a geoNear query, but not for a bounding-box $geoWithin query. In this case, all of the data is within the polygon bounded by longitude -90 to -80, and latitude 35 to 45. The only secondary index on the collection is
{"geometry" : "2dsphere"}.
> db.TirCSV.count({ "geometry" : { "$near" : { "$geometry" :
{ "type" : "Point", "coordinates" : [ -85.389 , 40.46]}}} , "$or" : [
{ "data_type" : "tir"}]})
3017
> db.TirCSV.find({geometry : {$geoWithin : {$geometry : {type : "Polygon", coordinates: [[[-90,45],[-90,35],[-80,35],[-80,45],[-90,45]]]}}}}).count()
3063
> db.TirCSV.count(
)
3063
> db.TirCSV.reIndex()
{
"nIndexesWas" : 2,
"msg" : "indexes dropped for collection",
"nIndexes" : 2,
"indexes" : [
{
"key" :
,
"ns" : "sparcTest.TirCSV",
"name" : "id"
},
{
"key" :
,
"ns" : "sparcTest.TirCSV",
"name" : "geometry_2dsphere"
}
],
"ok" : 1
}
> db.TirCSV.count({ "geometry" : { "$near" : { "$geometry" :
}} , "$or" : [
{ "data_type" : "tir"}]})
3016
> db.TirCSV.find({geometry : {$geoWithin : {$geometry : {type : "Polygon", coordinates: [[[-90,45],[-90,35],[-80,35],[-80,45],[-90,45]]]}}}}).count()
3063