MongoDB查找带有1M文档的DOT的字段
我正在尝试查找查询,以查找收藏集中的所有字段/键,其中有1M记录。该场是一个嵌套字段(在字段下的字段下的字段)。但是我最终会通过输出对如何克服这一点提出任何建议?
mr = db.runCommand({
"mapreduce" : "MyCollectionName",
"map" : function() {
var f = function() {
for (var key in this) {
if (this.hasOwnProperty(key)) {
emit(key, null)
if (typeof this[key] == 'object') {
f.call(this[key])
}
}
}
}
f.call(this);
},
"reduce" : function(key, stuff) { return null; },
"out": "MyCollectionName" + "_keys"
});
print(db[mr.result].distinct("_id"));
lmdb>打印(DB [Mr.Result] .distinct(“ _ id”));
获取此错误: Mongoservererror:太大,16MB上限
我对Mongodb来说是个新手,所以请原谅我的无知…
I am trying to find the query to find all the fields/keys in the collection with 1M records. The field is a nested field (field under a field under field). But I end up getting this error with output any suggestions on how to overcome this ??
mr = db.runCommand({
"mapreduce" : "MyCollectionName",
"map" : function() {
var f = function() {
for (var key in this) {
if (this.hasOwnProperty(key)) {
emit(key, null)
if (typeof this[key] == 'object') {
f.call(this[key])
}
}
}
}
f.call(this);
},
"reduce" : function(key, stuff) { return null; },
"out": "MyCollectionName" + "_keys"
});
print(db[mr.result].distinct("_id"));
lmdb> print(db[mr.result].distinct("_id"));
getting this error:
MongoServerError: distinct too big, 16mb cap
I am fairly new to mongodb, so forgive my ignorance…
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建包含所有字段名称的新集合。您似乎在此集合上使用了“ _id”字段上的独特之处,“ _id”在定义上是唯一的,因此只能运行
“ db。{collectionName} .find({})”
而不是不同。另外,指出,扩张结果不得超过最大BSON大小(16 MB)。您可以使用汇总选项为此。像这样:
Once you create new collection containing all the field names. You seem to be using distinct on "_id" field for this collection, "_id" are unique by definition, so can just run
"db.{collectionName}.find({})"
instead of distinct. Also, mongo docs explicitly state that distict results must not exceed max BSON size (16 Mb).You can use use aggregate option for that. Like this: