问题描述
专家.
我是 MongoDB 的新手,但我知道的足够让我自己陷入困境.例如:
I'm new to MongoDB, but know enough to get my self in trouble.. case in point:
db.test.aggregate(
[
{$group: {_id: {email: "$email", gender: "$gender"}, cnt: {$sum: 1}}},
{$group: {_id: "$_id.email", cnt: {$sum: 1}}},
{$match: {cnt: 2}}
],
{allowDiskUse : true}
)
无论我尝试什么变体,我都会收到相同的错误(Pass allowDiskUse:true to opt in"):
and no matter what variations I try, I keep getting the same error ("Pass allowDiskUse:true to opt in"):
Error("打印堆栈跟踪")@:0 ()@src/mongo/shell/utils.js:37([对象数组],[对象对象])@src/mongo/shell/collection.js:866@(shell):7
未捕获的异常:聚合失败:{errmsg":异常:从 mongo1.mscnet.com:27017 收到错误响应:{ $err:"超过 $group 的内存限制,但不允许外部排序.通过 allowDiskUse:true 选择加入.", code: 16945 }", "code" : 16945,好":0}
uncaught exception: aggregate failed: { "errmsg" : "exception: Received error in response from mongo1.mscnet.com:27017: { $err: "Exceeded memory limit for $group, but didn't allow external sort. Pass allowDiskUse:true to opt in.", code: 16945 }", "code" : 16945, "ok" : 0 }
仅供参考:我使用的是 Mongo 2.6
FYI: I'm using Mongo 2.6
推荐答案
请在运行命令中使用聚合查询,允许使用allowDiskUse标签.
Please use aggregate query in run command,it will allow to use allowDiskUse tag.
db.runCommand(
{ aggregate: "test",
pipeline: [
{$group: {_id: {email: "$email", gender: "$gender"}, cnt: {$sum: 1}}},
{$group: {_id: "$_id.email", cnt: {$sum: 1}}},
{$match: {cnt: 2}}
],
allowDiskUse: true
}
)
这篇关于MongoDB 允许磁盘使用不工作..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!