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

Geo serialization should accept legacy coordinates as sub-object regardless of field names

    • Query Integration
    • ALL
    • 200

      You are allowed to pass legacy coordinate pairs as either an array (e.g., [1,0]) or as an embedded document (e.g., {x: 1, y: 0}). According to the docs, for the embedded document approach you can provide any field names, and the fields will be treated as longitude and latitude in respective order. That means you could use $geometry and $minDistance as field names to specify the coordinates, like

      db.geo.find({loc: {$nearSphere: {$geometry: 128, $minDistance: 0.1}}}) 

      This query will act equivalent to 

      db.geo.find({loc: {$nearSphere: [128, 0.1]}}) 

       

      These queries execute the same, but the first one fails to serialize when queryStats is enabled since it expected any $geometry field to have a sub-object. 

            Assignee:
            will.buerger@mongodb.com Will Buerger
            Reporter:
            will.buerger@mongodb.com Will Buerger
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: