$connection = new MongoDB\Driver\Manager("mongodb://localhost:27017");
$db = "db";
$coll = "calls";
$filter = [];
$options= [];
$coll = "calls";
$Client= "linux";
$query = new MongoDB\Driver\Command(['count' => $coll, 'query' => ['Client' => ['$text' => ['$search' => $Client]]]]);
$result = $connection->executeCommand($db,$query);
$res = current($result->toArray());
$countAll = $res->n;
echo ("Total linux clients \"Unknown\": " . $countAll . "\n");
为什么这个脚本会抛出 $text operator is unknown 的错误?如果我在其他字段中使用 $gt 或 $eq 但语法相同,它们就可以工作。只有 $text 不会。
目标是统计具有内容为“linux”(例如linux-1、linux0.7等)的 Client 字段的文档。
至尊宝的传说