0

I wrote a mongodb query and trying to join(look up) two collections using Mongo query but it is throwing me an error saying maximum document size exceeds. Same query in running on small collection where 150 documents are there but failing to work on 2.9 million documents. I need help in this.

I am using Studio 3T for MongoDB 2018.6.1 IDE

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

Unable to execute the selected commands

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. 

The full response is:

{ 
    "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"
}
Ashh
  • 44,693
  • 14
  • 105
  • 132
teja
  • 21
  • 6
  • 1
    The error clearly says that matching documents exceeded the maximum document size i.e. **16mb**. – Ashh Jan 02 '19 at 04:20
  • Hello, thanks. I understood that but how do I use a 'Lookup' to join the 2 collections which contain around 3 million documents? – teja Jan 02 '19 at 04:25
  • What version of mongo you are using? – Ashh Jan 02 '19 at 04:26
  • I'm using MongoDB 3.4 – teja Jan 02 '19 at 04:29
  • This is what you are looking for https://stackoverflow.com/questions/45724785/aggregate-lookup-total-size-of-documents-in-matching-pipeline-exceeds-maximum-d/45726501#45726501 – Ashh Jan 02 '19 at 04:30
  • I think this is really helpful for me thank you. – teja Jan 02 '19 at 04:38

0 Answers0