Chapter 3 $lookup lab: "OneWorl" the most routes alliance

Doing the pipeline indicated in the “detailed answer” the result returned by the pipeline is not “SkyTeam”.

the alliance with the most routes is “OneWorld”.
Does any body else had “OneWorld” as the most routes alliance?

    $match: {
      airplane: /747|380/
    $lookup: {
      from: "air_alliances",
      foreignField: "airlines",
      localField: "",
      as: "alliance"
    $unwind: "$alliance"
    $group: {
      _id: "$",
      count: { $sum: 1 }
    $sort: { count: -1 }

are you on the correct database? It is possible you have used the query on “sample dataset” available for new clusters.

M121 uses a different read-only database and the connection link is given in the first chapter.

I am using the connection link given in the first chapter and I use the collections indicated in each lab.

I have just went through and used both Compass and mongosh and get the expected results using the connection string from the course, so I can confirm that the query does work.

1 Like

if you are really sure (!) you are on the correct database, then you have just split the query wrong when trying to enter it into stages on Compass. Please try again.

The aggregation framework is fun and great to use but is not forgiving if you ignore the order of pipelines.

Give relaxation breaks and do not try to finish the course in one day. there is a lot to learn but if you grasp the main ideas all will be like a toy to play with.

Dears mongoDb Mates,
I want to thank all of you for participate in this topic. Your answers help me to search and find my mistake. I have commited one small mistake that change everything and It was in the $match stage: /780|380/ instead of /747|380/.
Now I have the result just like should be.
Thank you very much
see you!!