[SERVER-8592] Projecting a field that has a 2dsphere index gets the geohash and not the actual coordinates Created: 15/Feb/13  Updated: 29/Jan/15  Resolved: 29/Jan/15

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: 2.4.0-rc0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Sridhar Nanjundeswaran Assignee: David Storch
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

2.4.0-rc0 on OSX


Issue Links:
Depends
is depended on by SERVER-8621 Non covered geo query is reported as ... Closed
Operating System: ALL
Steps To Reproduce:

var coll = db.getCollection("geoprojection")
coll.drop()
coll.insert({_id : 1, loc : {type:"Point", coordinates:[ 5 , 5 ]}, foo : 1})
coll.insert({_id : 2, loc : {type:"Point", coordinates:[ 5 , 5 ]}, foo : 2})
coll.insert({_id : 3, loc : {type:"Point", coordinates:[ 5 , 5 ]}, foo : 3})
coll.ensureIndex({foo: 1, loc : "2dsphere"});
 
coll.find({foo : {$lt:3}}, {foo:1, loc:1, _id:0}).hint({foo: 1, loc:"2dsphere"});

Participants:

 Description   

Expected to get

{ "loc" : { "type" : "Point", "coordinates" : [ 5, 5 ] }, "foo" : 1 }
{ "loc" : { "type" : "Point", "coordinates" : [ 5, 5 ] }, "foo" : 2 }

but get

{ "foo" : 1, "loc" : "0f20002222223122" }
{ "foo" : 2, "loc" : "0f20002222223122" }



 Comments   
Comment by David Storch [ 29/Jan/15 ]

This was fixed in 2.6 as part of the rewrite of the query engine:

> db.version()
2.6.7
> var coll = db.getCollection("geoprojection")
> coll.drop()
true
> coll.insert({_id : 1, loc : {type:"Point", coordinates:[ 5 , 5 ]}, foo : 1})
WriteResult({ "nInserted" : 1 })
> coll.insert({_id : 2, loc : {type:"Point", coordinates:[ 5 , 5 ]}, foo : 2})
WriteResult({ "nInserted" : 1 })
> coll.insert({_id : 3, loc : {type:"Point", coordinates:[ 5 , 5 ]}, foo : 3})
WriteResult({ "nInserted" : 1 })
> coll.ensureIndex({foo: 1, loc : "2dsphere"});
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 1,
	"numIndexesAfter" : 2,
	"ok" : 1
}
>
> coll.find({foo : {$lt:3}}, {foo:1, loc:1, _id:0}).hint({foo: 1, loc:"2dsphere"});
{ "loc" : { "type" : "Point", "coordinates" : [ 5, 5 ] }, "foo" : 1 }
{ "loc" : { "type" : "Point", "coordinates" : [ 5, 5 ] }, "foo" : 2 }

Closing as a duplicate of SERVER-10026.

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