要运行聚合查询,可以使用以下任何一种:
db.collectionName.aggregate(query1);
或者
db.runCommand(query2)
但是今天早上我注意到了一些奇怪的事情。虽然这样:
db.runCommand(
{
"aggregate":"collectionName",
allowDiskUse: true,
"pipeline":[
{
"$match":{
"field":param
}
}
]
});
失败并出现错误:
{
"ok" : 0.0,
"errmsg" : "aggregation result exceeds maximum document size (16MB)",
"code" : 16389,
"codeName" : "Location16389"
}
这个:
db.collectionName.aggregate([
{
$match: {
field: param
}
}
])
正在工作(给出预期的聚合结果)。
这怎么可能?