Chapter 1: Lab - $match

Hey guys,

No issues running find() on movies collection, however, keep getting this error when trying to run aggregate function:

MongoDB Enterprise Cluster0-shard-0:PRIMARY> db.movies.aggregate([{"$match": { “genres”: { $nin: [“Crime”,“Horror”]} }}])
2019-01-19T14:41:34.785+1100 E QUERY [js] Error: error doing query: failed: network error while attempting to run command ‘aggregate’ on host ‘cluster0-shard-00-01-jxeqq.mongodb.net:27017’ :
DB.prototype.runCommand@src/mongo/shell/db.js:168:1
DB.prototype.runReadCommand@src/mongo/shell/db.js:139:16
DB.prototype._runAggregate/doAgg<@src/mongo/shell/db.js:239:60
DB.prototype._runAggregate@src/mongo/shell/db.js:242:21
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1062:12
@(shell):1:1
2019-01-19T14:41:34.786+1100 I NETWORK [js] Marking host cluster0-shard-00-01-jxeqq.mongodb.net:27017 as failed :: caused by :: Location40657: Last known master host cannot be reached

Has anyone come across this previously?

Thanks.

This error may happen when I didn’t send any query or anything to the host in a long time . It seems like the host close the connection for efficiency . And it will reconnect immediately then, after reporting the error.

with below , i am getting 9 records. should get 23

db.movies.aggregate( < deleted >

Please follow forum guidelines and do not post code that are potential answers.

The following link will help you.

https://docs.mongodb.com/manual/reference/operator/aggregation/in/

@Sushil_90850

Please follow Forum guidelines and do not post code or answers – correct or otherwise – here. I have edited your post accordingly.

Also notice that you are attaching a new question to an old thread. I would strongly recommend that you start a new post for a new question.