首页 > 解决方案 > 尝试使用 Mongo 查询加入(查找)两个集合,但它给我一个错误

问题描述

我写了一个 mongodb 查询并尝试使用 Mongo 查询加入(查找)两个集合,但它给我一个错误,说最大文档大小超出。在有 150 个文档但无法处理 290 万个文档的小型集合上运行相同的查询。我需要这方面的帮助。

我正在为 MongoDB 2018.6.1 IDE 使用 Studio 3T

db.collection.aggregate([
  {
    $lookup: {
      from: "collection2",
      localField: "id",
      foreignField: "id",
      as: "joined_data"
    }
  }
])

无法执行选定的命令

Mongo Server error (MongoCommandException): Command failed with error 4568 (Location4568): 'Total size of documents in collection2 matching pipeline { $match: { $and: [ { id: { $eq: null } }, {} ] } } exceeds maximum document size' on server 168.152.169.555:27017. 

完整的回应是:

{ 
    "ok" : 0.0, 
    "errmsg" : "Total size of documents in collection2 matching pipeline { $match: { $and: [ { id: { $eq: null } }, {} ] } } exceeds maximum document size", 
    "code" : NumberInt(4568), 
    "codeName" : "Location4568"
}

标签: mongodb

解决方案


推荐阅读