Bring it all lab

` xMax = 1521105;
xMin = 5;

var pipeline = [
  {
$addFields: {
  votes: "$imdb.votes",
  rating: "$imdb.rating",
  released: {
    $year: "$released",
  },
},
  },
  {
$match: {
  languages: { $in: ["English"] },
  released: {
    $gte: 1990,
  },
},
  },
  {
$project: {
  _id: 0,
  title: 1,
  rescale_votes: {
    $add: [
      1,
      {
        $multiply: [
          9,
          {
            $divide: [
              { $subtract: ["$votes", xMin] },
              { $subtract: [xMax, xMin] },
            ],
          },
        ],
      },
    ],
  },
},
  },
];

db.movies.aggregate(pipeline).pretty();

`
I’m getting a error $substract don’t accept string. but votes return a int. I’ve tryid $convert and $toInt but I’ve got an error saying that votes is empty, but when a I made agregations without the rescale. vote is defined…

I found out what was the problem… indeed I miss some fields in $match… :sweat_smile: