micoco
micoco

Reputation: 299

Maximum document size exceeded

This a pretty common problem in MongoDB but I couldn't find anything that could help. I am trying to aggregate two collections containing a common key but I get a "maximum document size exceeded" error.

The Meal collection is every meal consumed by a specific individual while HasConsumed is every food this individual has eaten during the meal.

Meal contains 171318 items while HasConsumed contains 541526 items.

Here's the query :

    db.getCollection('Meal').aggregate(
    {
       $lookup:
         {
           from: "HasConsumed",
           localField: "nomen_nojour_tyrep",
           foreignField: "nomen_nojour_tyrep",
           as: "conso"
         }},
        { $out : "hasConsumed" }
    )

Upvotes: 0

Views: 275

Answers (1)

Atish
Atish

Reputation: 4417

Use allowDiskUse option in your pipeline:

 db.getCollection('Meal').aggregate([
    {
       $lookup:
         {
           from: "HasConsumed",
           localField: "nomen_nojour_tyrep",
           foreignField: "nomen_nojour_tyrep",
           as: "conso"
         }},
        { $out : "hasConsumed" }


    ],{ allowDiskUse: true} )

Upvotes: 1

Related Questions