I'm so confusing what i was learn in this part

In Chapter 2: User-Facing Backend

Ticket: Faceted Search

Here is implemented code about the aggregation facet.

    const facetStage = {
      $facet: {
        runtime: [
          {
            $bucket: {
              groupBy: "$runtime",
              boundaries: [0, 60, 90, 120, 180],
              default: "other",
              output: {
                count: { $sum: 1 },
              },
            },
          },
        ],
        rating: [
          {
            $bucket: {
              groupBy: "$metacritic",
              boundaries: [0, 50, 70, 90, 100],
              default: "other",
              output: {
                count: { $sum: 1 },
              },
            },
          },
        ],
        movies: [
          {
            $addFields: {
              title: "$title",
            },
          },
        ],
      },
    }

I passed the lab, but I don’t know how it works and what I get when I finish the lab without any explanation to this stage. I need more explanation about this or received committed to explaining in the next chapter.
I don’t think in the previous lecture, I have gotten all enough about “basic aggregation” to understand that string :frowning:

Hi @Th_ng_Nguy_n_Quy_t,
You can learn more about the $facet stage here:

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

Thanks and Regards.
Sourabh Bagrecha,
Curriculum Services Engineer

1 Like