Specifying a query hint that points to a non-existent index produces a rather generic error message:
Fatal error: Uncaught exception 'MongoDB\Driver\Exception\ConnectionException' with message 'failed on : shard0000' in app/vendor/composer/mongodb/mongodb/src/Operation/Count.php:111 Stack trace: #0 app/vendor/composer/mongodb/mongodb/src/Operation/Count.php(111): MongoDB\Driver\Server->executeCommand('keywords', Object(MongoDB\Driver\Command), Object(MongoDB\Driver\ReadPreference)) #1 app/vendor/composer/mongodb/mongodb/src/Collection.php(233): MongoDB\Operation\Count->execute(Object(MongoDB\Driver\Server)) #2 app/scratch08.php(20): MongoDB\Collection->count(Array, Array) #3 {main} thrown in app/vendor/composer/mongodb/mongodb/src/Operation/Count.php on line 111
It would be awesome if the error message hinted at what went wrong.
Reproduce case:
$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017"); $col = new \MongoDB\Collection($manager, 'keywords', 'keywords'); $res = $col->count( [ '_id' => [ '$in' => [] ] ], [ 'hint' => [ '_not_exists' => 1 ] ] );