Skip to content

Add methods to route all ES commands to bulk #109

@AnatolyRugalev

Description

@AnatolyRugalev

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions