[SERVER-86310] $addFields with $meta: "recordId" doesn't add new field Created: 06/Feb/24  Updated: 07/Feb/24

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Vishnu Kaushik Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-86296 Existing $recordId field hidden when ... Needs Scheduling
Assigned Teams:
Query Execution
Operating System: ALL
Participants:

 Description   

We see that the new field, which should equal the recordId, is not added to the output:

> db.newcoll.insert({a: 1})
WriteResult({ "nInserted" : 1 })
> db.newcoll.aggregate([{$addFields: {rid: {$meta: "recordId"}}}])
{ "_id" : ObjectId("65c281f44bb7df438ffb4d1e"), "a" : 1 }

However this works with $project instead:

db.newcoll.aggregate([{$project:{rid: {$meta: "recordId"}} }])
{ "_id" : ObjectId("65c289a24bb7df438ffb4d2a"), "rid" : NumberLong(6) }

See comments for more info.


Generated at Thu Feb 08 06:59:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.