-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
ALL
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Compare these two aggs and their transformBy:
db.notification.explain(true).aggregate([{ "$match": { "created": { "$gte": { "$date": "2025-02-01T00:00:00Z" }, "$lt": { "$date": "2025-08-01T00:00:00Z" } } } }, {"$addFields":{"xxx": {"$toString": "$created" }}}, { "$group": { "_id": "$xxx"}}])
Results in
transformBy: { created: 1, _id: 0 },
while
db.notification.explain(true).aggregate([{ "$match": { "created": { "$gte": { "$date": "2025-02-01T00:00:00Z" }, "$lt": { "$date": "2025-08-01T00:00:00Z" } } } }, {"$addFields":{"xxx": {new: {"$toString": "$created" }}}}, { "$group": { "_id": "$xxx"}}])
Results in
transformBy: { created: 1, xxx: 1, _id: 0 },
Moving the `\$toString:"\$existingFIeld" into subdocument caused us to lose track of something and think that `xxx` was somehow a field from the original document...
- is related to
-
SERVER-25120 aggregation requests generated field name from query
-
- Closed
-