Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregation problem with 'cursor' option #228

Closed
kalyashka opened this issue Sep 6, 2017 · 1 comment
Closed

Aggregation problem with 'cursor' option #228

kalyashka opened this issue Sep 6, 2017 · 1 comment
Assignees
Labels
Milestone

Comments

@kalyashka
Copy link

What steps will reproduce the problem?

$collection->aggregate($pipeline, ['cursor' => ['batchSize' => 100]]);

What's expected?

Aggregation result

What do you get instead?

yii\base\ErrorException: Undefined index: result in .../vendor/yiisoft/yii2-mongodb/Command.php:734

Additional info

When aggregating with a large number of documents, mongodb produces an error "exception: aggregation result exceeds maximum document size (16MB)". In the mongodb manual, it is recommended that you use a cursor or temporary collection.
As I understand, yii2-mongodb uses a query variant, in which all results are returned as a single document. If this document large enough, mongodb will fail with BSON limit. When setting the 'cursor' option, mongodb returns the documents as an array (cursor). The element 'result' is missing in the results
I propose to enable the 'cursor' option by default and treat the result as a cursor.

Q A
Yii version 2.0.12
Yii MongoDB version 2.1.4
MongoDB server version v3.4.8-rc1
PHP version 7.1.1
Operating system Linux Mint
@kalyashka kalyashka changed the title Aggregation problem with cursor option Aggregation problem with 'cursor' option Sep 6, 2017
@klimov-paul klimov-paul added the status:to be verified Needs to be reproduced and validated. label Sep 7, 2017
@klimov-paul klimov-paul self-assigned this Sep 7, 2017
@klimov-paul klimov-paul added type:bug Bug and removed status:to be verified Needs to be reproduced and validated. labels Sep 7, 2017
@klimov-paul klimov-paul added this to the 2.1.5 milestone Sep 7, 2017
@klimov-paul
Copy link
Member

Resolved by commit 9395f07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants