Database

[{"_id":ObjectId("6251f8556e75125f9260f333"),"name":"jojo","profile":"jojo profile","date":ISODate("2022-04-09T21:18:40.473Z"),"look":[{"art":"group-id","data":"alma","dt":"1"},{"art":"called","data":"central","dt":"1"},{"art":"access-time","data":108000,"dt":"1"}],"answer":[{"art":"rate-id","data":"limit1","dt":"1"},{"art":"protocol","data":"tcp","dt":"1"}]},{"_id":ObjectId("6251f8306e75125f9260f332"),"name":"dodo","profile":"dodo profile","date":ISODate("2022-04-09T15:20:58.562Z"),"look":[{"art":"group-id","data":"alma","dt":"1"},{"art":"called","data":"central","dt":"1"},],"answer":[{"art":"rate-id","data":"limit1","dt":"1"},]},{"_id":ObjectId("6251a5113700ba4a0a59c48f"),"name":"kaka","profile":"kaka profile","date":ISODate("2022-04-09T15:22:25.816Z"),"look":[{"art":"access-time","data":50400,"dt":"1"}],"answer":[{"art":"protocol","data":"tcp","dt":"1"}]}]

Query

db.collection.aggregate([{$replaceRoot:{newRoot:{"$mergeObjects":[{_id:"$_id",name:"$name",profile:"$profile",date:"$date",},{"$arrayToObject":{$map:{input:{$filter:{input:{$objectToArray:{$ifNull:[{"$arrayElemAt":[{$filter:{input:{$ifNull:["$look",[]]},cond:{$eq:["$$this.art","group-id"]}}},0]},{art:""}]}},cond:{$eq:["$$this.k","data"]}}},in:{k:"goup",v:"$$this.v"}}}},{"$arrayToObject":{$map:{input:{$filter:{input:{$objectToArray:{$ifNull:[{"$arrayElemAt":[{$filter:{input:{$ifNull:["$look",[]]},cond:{$eq:["$$this.art","called"]}}},0]},{art:""}]}},cond:{$eq:["$$this.k","data"]}}},in:{k:"called",v:"$$this.v"}}}},{"$arrayToObject":{$map:{input:{$filter:{input:{$objectToArray:{$ifNull:[{"$arrayElemAt":[{$filter:{input:{$ifNull:["$look",[]]},cond:{$eq:["$$this.art","access-time"]}}},0]},{art:""}]}},cond:{$eq:["$$this.k","data"]}}},in:{k:"access-time",v:"$$this.v"}}}},{"$arrayToObject":{$map:{input:{$filter:{input:{$objectToArray:{$ifNull:[{"$arrayElemAt":[{$filter:{input:{$ifNull:["$answer",[]]},cond:{$eq:["$$this.art","rate-id"]}}},0]},{art:""}]}},cond:{$eq:["$$this.k","data"]}}},in:{k:"rate",v:"$$this.v"}}}},{"$arrayToObject":{$map:{input:{$filter:{input:{$objectToArray:{$ifNull:[{"$arrayElemAt":[{$filter:{input:{$ifNull:["$answer",[]]},cond:{$eq:["$$this.art","protocol"]}}},0]},{art:""}]}},cond:{$eq:["$$this.k","data"]}}},in:{k:"protocol",v:"$$this.v"}}}}]}}}])

Result