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

Add methods to route all ES commands to bulk #109

Open
AnatolyRugalev opened this issue Oct 5, 2016 · 1 comment
Open

Add methods to route all ES commands to bulk #109

AnatolyRugalev opened this issue Oct 5, 2016 · 1 comment
Labels
type:enhancement Enhancement

Comments

@AnatolyRugalev
Copy link

AnatolyRugalev commented Oct 5, 2016

Just look at this code:

$models = EsPost::find()->andWhere(['author' => $id])->all();
foreach($models as $model) {
    $model->doSomething();
    $model->save();
}

This produces multiple ES requests, but it is really possible to make a bulk of them:

$models = EsPost::find()->andWhere(['author' => $id])->all();
EsPost::getDb()->beginBulk();
foreach($models as $model) {
    $model->doSomething();
    $model->save();
}
EsPost::getDb()->executeBulk();

What do you think?

I already implemented this feature and can make a PR if you are interested

@beowulfenator
Copy link
Collaborator

That's a great idea. So a connection goes into "bulk mode", operations get accumulated internally, and then executed in one fell swoop with executeBulk?

Go ahead and submit your PR!

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

No branches or pull requests

2 participants