For Lab - Computing field in Chapter 1
Why cant i match the size of array myfield in the match stage using the below command-
db.movies.aggregate([ { $project: { myfield:{ $split: ["$title", " "] } } }, {$match:{1:{$eq:{$size:myfield}}}} ]).itcount()
It gives me error -
ReferenceError: myfield is not defined :
Whereas if i create myfield as size of array itself in projection stage, i am getting correct ans. Command used-
db.movies.aggregate([ { $project: { myfield:{$size:{ $split: ["$title", " "] }} } }, {$match:{myfield:{$eq:1}}} ]).itcount()