为什么mongo aggregate在shell中工作,但在PHP中超过16MB
我有一个相当庞大的mongo聚合命令为什么mongo aggregate在shell中工作,但在PHP中超过16MB,php,mongodb,mongo-shell,Php,Mongodb,Mongo Shell,我有一个相当庞大的mongo聚合命令 db.container_product.aggregate([ {"$unwind":"$product"}, {"$group":{"_id":"$product","container_ids":{"$push":"$container_id"}}} ]) 结果几乎是5k组,但它们都是纯整数。例如: { "_id" : NumberInt(107058402), "container_ids" : [
db.container_product.aggregate([
{"$unwind":"$product"},
{"$group":{"_id":"$product","container_ids":{"$push":"$container_id"}}}
])
结果几乎是5k组,但它们都是纯整数。例如:
{
"_id" : NumberInt(107058402),
"container_ids" : [
NumberInt(107058409),
NumberInt(107058410),
NumberInt(107058411),
NumberInt(107058412),
NumberInt(107058413)
]
}
当我在shell中运行它时,它工作得很好(普通shell,但也有Robomongo等)。但是当我尝试从PHP运行它时,它会给我16MB的错误
172.16.0.2:27017:异常:聚合结果超过最大文档大小(16MB)
在这种情况下,PHP和shell之间的巨大区别是什么
如何解决此问题?Shell使用的js包装器隐式使用,因此它可以返回任意大小的结果(每个文档的限制仍然适用)。通过在shell中调用
db.collection.aggregate
,可以查看包装器的源代码
在PHP中,直接调用命令以返回单个文档,而不是游标。你需要改用