Aggregation 1: Average lifetime gross by studio

To solve this challenge, we can use the terms aggregation on the studio attribute combined with the avg aggregation lifetime_gross.

To implement this aggregation, we will initiate a _search request targeting the movie index, and within the request body, we will define the aggregation structure. Initially, we will specify aggs as terms and designate the field as studio. Nested within this aggregation, we will include another aggs section labeled as avg, where we will specify the field as lifetime_gross.

Get hands-on with 1400+ tech skills courses.