Chapter 3 Lab 2, matching airplanes

in my initial match I used this:
airplane: {$in: [“747”, “380”]}

It worked and I got 23 routes total, with:
SkyTeam: 8
OneWorld: 10
Star Alliance: 5

Of course, that is not the correct answer and if I instead use this in my match:
airplane: /747|380/

I get the correct answer. What I don’t understand is why those are not equivalent.

1 Like

The field airplane is not an array for some (and maybe for all) documents. When $in is used with a string field it is equivalent to

airplane equals 747 or airplane equals 380

However, airplane: /747|380/ is a regular expression that is equivalent to

airplane contains the substring 747 or the substring 380

If you take the following document

    "name":"Delta Air Lines",
  "airplane":"M11 333 747 74M 332"

you will see that airplane is not equal to 747 but does contain the substring 747.


Just got bitten by the same thing. Seems like a pointlessly punitive “gotcha” lab - at the very least, the variable data formats should be mentioned in the instructions.

1 Like