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

Comments

Projects
None yet
2 participants
@kalyashka

kalyashka commented Sep 6, 2017

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 from Aggregation problem with cursor option to Aggregation problem with 'cursor' option Sep 6, 2017

@klimov-paul klimov-paul self-assigned this Sep 7, 2017

@klimov-paul klimov-paul added this to the 2.1.5 milestone Sep 7, 2017

@klimov-paul

This comment has been minimized.

Show comment
Hide comment
@klimov-paul

klimov-paul Sep 7, 2017

Member

Resolved by commit 9395f07

Member

klimov-paul commented Sep 7, 2017

Resolved by commit 9395f07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment