Mr. Felix Mr. Felix - 7 months ago 82
PHP Question

MongoDB unwind commands

I'm trying to unwind an array inside a document.

{ //document
parameters : [{...}, {...}, ...]

Here is a working command:

{ $unwind : "$parameters" }

I'm trying to use
to do the same task:

aggregate: "inventory",
pipeline: [{ $unwind: "$parameters" }]

But with this second options, I'm getting this error:

aggregation result exceeds maximum document size (16MB)

Aren't these commands the same? Why the second one is not working?

I'm using Mongo PHP Driver for PHP 7, that's why I'm aggregating in this way.


db.runCommand returns the result inside one document. So, all the aggregation result is larger than 16MB. Setting batchSize at cursor option might solve the problem.

Using MongoDB::execute, I can execute a query in this way: db.collection.aggregate(... just passing the original mongo syntax.