I have a collection of documents containing an array of objects:
db.collection.insert({ arr: [ { id: 1, text
You can use $let with $arrayElemAt to define temporary variable and then reference it to get text field:
text
db.collection.aggregate([ { $addFields: { text1: { $let: { vars: { first: { $arrayElemAt: [ "$arr", 0 ] } }, in: "$$first.text" } } } } ])