Mr. Felix Mr. Felix - 1 year ago 204
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download