Extra document returned for $match - lab

I am working on the first lab for m121… I have created an aggregation pipeline which seems to work, but returns 24 documents instead of the expected 23… can anyone see where I am going wrong here? Thanks for any help

[
  {
    '$match': {
      'imdb.rating': {
        '$gte': 7
      }
    }
  }, {
    '$match': {
      'genres': {
        '$ne': [
          'Crime', 'Horror'
        ]
      }
    }
  }, {
    '$match': {
      '$or': [
        {
          'rated': 'PG'
        }, {
          'rated': 'G'
        }
      ]
    }
  }, {
    '$match': {
      '$and': [
        {
          'languages': 'English'
        }, {
          'languages': 'Japanese'
        }
      ]
    }
  }
]

Hi @Brett_Larson,

Few things to get you started with your aggregation pipeline:

  1. When you use a $match stage, you can use all the query filters in the single $match stage, comma-separated.
  2. I would recommend you to check the documentation for the $in, $nin, $all operators to understand their usage.

Please feel free to reach out if you have any questions.

Kind Regards,
Sonali Mamgain

1 Like