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

XMLWordPrintableJSON

    • Query Optimization
    • Minor Change
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      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:
            [DO NOT USE] Backlog - Query Optimization
            Reporter:
            Kyle Suarez (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: