[SERVER-7322] GeoLoc does not match exact locations in 2.2.0 when there is more than one item in an index Created: 11/Oct/12  Updated: 11/Jul/16  Resolved: 07/Dec/12

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: 2.2.0
Fix Version/s: 2.3.2

Type: Bug Priority: Major - P3
Reporter: David Hows Assignee: hari.khalsa@10gen.com
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Operating System: ALL
Participants:

 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.



 Comments   
Comment by auto [ 08/Dec/12 ]

Author:

{u'date': u'2012-12-08T16:47:16Z', u'email': u'tad@10gen.com', u'name': u'Tad Marshall'}

Message: SERVER-7322 Fix Linux compile

Some versions of g++ issue a warning on copying a double to an int:

src/mongo/db/geo/2d.cpp:79: warning: converting to 'int' from 'double'

Other g++ versions do not complain. Use static_cast<int> to prevent warning.
Branch: master
https://github.com/mongodb/mongo/commit/37147146cb07e6bf0c0e47d4151d893a318ada31

Comment by auto [ 07/Dec/12 ]

Author:

{u'date': u'2012-12-07T22:14:55Z', u'email': u'hkhalsa@10gen.com', u'name': u'Hari Khalsa'}

Message: SERVER-7322 respect indexing order in 2d
Branch: master
https://github.com/mongodb/mongo/commit/9a6add74dfb76a15c565913d9fe4b4fc71e11934

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