I am just having difficulties to understand this, how can I list outer-most fields when I am working with a huge text datasets? I am trying to implement it in Mongodb and pymongo? any suggestions?
I am not sure what you need, but maybe the bellow can help.
Query
aggregate(
[{"$project":
{"_id": 0,
"outer-fields":
{"$map":
{"input":
{"$map":
{"input": {"$objectToArray": "$$ROOT"},
"in": ["$$m.k", "$$m.v"],
"as": "m"}},
"in": {"$arrayElemAt": ["$$this", 0]}}}}}])