Chapter 4: Core Aggregation - Multidimensional Grouping - Need a hint

I’m trying to solve Lab for Chapter #4, but I don’t have a clue on the path to do that…

I need to find the top 10 for 2 different fields, get the intersection from those 2 arrays, and count the lines on that.

I can’t figure out how to use facets to solve that. I’m trying to figure out a way to create the 2 arrays with 10 elements. If I understood right, facet is a way to group. And I can’t figure out how to use that to generate those arrays.

Hope someone enlightens this for me… Please.

Hi @Elton_Morais, :wave:
Please note that the $facet stage:

Processes multiple aggregation pipelines within a single stage on the same set of input documents. Each sub-pipeline has its own field in the output document where its results are stored as an array of documents.

Therefore, you can easily find the top 10 docs for 2 different fields and then all you need to do is find their intersection.

In case you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
Curriculum Services Engineer