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

$geoNear "distanceField" and "includeLocs" options unnecessarily overwrite existing paths

    • Query Optimization
    • Minor Change

      Consider a collection with documents of the shape

      {
          loc: {type: "Point", coordinates: [1.2, 1.1]},
          nested: {field: 7}
      }
      

      This aggregation using the $geoNear stage computes new fields in "nested":

      db.collection.aggregate({
          $geoNear: {
              near: {type: "Point", coordinates: [0, 0]},
              distanceField: "nested.dist",
              includeLocs: "nested.pt"
          }
      })
      

      However, the aggregation system overwrites the field "nested.field", even though it could be preserved. This behavior occurs if the existing document field shares a prefix with either the "distanceField" or "includeLocs" options.

      This ticket is a request to preserve as much existing information as possible.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            kyle.suarez@mongodb.com Kyle Suarez
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: