Group by aggregation on nested document

Let's say I have five document with some nested data:
Doc 1 :

{
    id:1,
    facilities:[
    {
        type:"hospital"
    }   
    ],
    investigator:[{
         name"Robert"
           },
         {
            name:"Julie"
        }
    }],
}    

Doc 2

 {
      id:2,
     facilities:[
     {
         type:"medical"
     }   
     ],
     investigator:[{
          name"Robert"
            },
          {
             name:"Julie"
         }
     }],
 }   
Doc 3:
{
     id:3,
    facilities:[
     {
         type:"biological"
     }   
     ],
     investigator:[{
          name"David"
            },
          {
             name:"Julie"
         }
     }],
 }    

I want to search all document where the investigator name is "Robert" and I want it to return like this:

{
investigator_name:"Robert",
id_list:[{id:"1"} , {id:"2"}],
facilities_list:[{ type:"hospital"},{ type:"medical"}]

}

Is that even possible?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.