M121 Homework i'm not getting a number as resukt from running validate1 function with pipeline as argument

i'm not getting a number as ouput from running validate function

Atlas Cluster0-shard-0 [primary] aggregations> var pipeline = [ { $match: { $and:[ { "imdb.rating":{ $gt: 7}},{genres:{$nin:["Crime","Horror"]}},{rated:{$in:["PG","G"]}},{languages:{$all:["English","Japanese"]}}]} } ]

Atlas Cluster0-shard-0 [primary] aggregations> db.movies.aggregate(pipeline).itcount()
20
Atlas Cluster0-shard-0 [primary] aggregations> load('validateLab1.js')
true
Atlas Cluster0-shard-0 [primary] aggregations> validateLab1(pipeline)
You aren't returning the correct number of documents

Atlas Cluster0-shard-0 [primary] aggregations> 

this means your query works but is not as intended by the question. please check the keywords, especially "and"s and "or"s

Same Error !!

can some one please assist and identify anything wrong in the below Query. I get back 877 documents

var pipeline = [{"$match" : {"$and" : [{“imdb.rating” : {"$gte" : 7}},{“genres” : {"$nin" : [“Horror”,“Crime”]}},{"$or" : [{“rated” : “PG”}, {“rated” : “G”}]},{“languages” : {"$in" : [“English”,“Japanese”]}}]}}]

does not meet the requirement

languages contains “English” and “Japanese”

1 Like

And if I may add to

Your query produce 20 documents as seen in:

and the lab specifies 23 documents:

As a hint, your aggregation should return 23 documents. You can verify this by typing db.movies.aggregate(pipeline).itcount()

Do not try to validate until your pipeline produces 23 documents.

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.