yii\elasticsearch\Query::each PHP Method

each() public method

This method is similar to Query::batch except that in each iteration of the result, only one row of data is returned. For example, php $query = (new Query)->from('user'); foreach ($query->each() as $row) { }
Since: 2.0.4
public each ( string $scrollWindow = '1m', Connection $db = null ) : BatchQueryResult
$scrollWindow string how long Elasticsearch should keep the search context alive, in [time units](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units)
$db Connection the database connection. If not set, the `elasticsearch` application component will be used.
return BatchQueryResult the batch query result. It implements the [[\Iterator]] interface and can be traversed to retrieve the data in batches.
    public function each($scrollWindow = '1m', $db = null)
    {
        return Yii::createObject(['class' => BatchQueryResult::className(), 'query' => $this, 'scrollWindow' => $scrollWindow, 'db' => $db, 'each' => true]);
    }