Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-8592

Projecting a field that has a 2dsphere index gets the geohash and not the actual coordinates

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 2.4.0-rc0
    • Geo
    • None
    • 2.4.0-rc0 on OSX
    • ALL
    • Hide

      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"});

      Show
      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"});

    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" }

      Attachments

        Activity

          People

            david.storch@mongodb.com David Storch
            sridhar Sridhar Nanjundeswaran
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: