Using $lookup: abbreviated terms

I am struggling a bit with getting the right output for this lab. I try to clearly outline what I get after each stage:
$Match: air_routes using “780” or “380”
returns 44 documents
$Lookup: on air_routes from air_alliances
$Match: than $elemMatch: $exists true to eliminate empty arrays
$group: alliances and sum them

after this I get:
{ “_id” : [ “OneWorld” ], “allianceCount” : 10 }
{ “_id” : [ “SkyTeam” ], “allianceCount” : 8 }
{ “_id” : [ “Star Alliance” ], “allianceCount” : 5 }

Now I see KLM Royal Dutch Airlines is abbreviated to KLM in air_alliances… but not sure how to tackle the $lookup if it is comparing on abbreviated names.

some air_routes have both air planes separated with a string

2 Likes