batch() public method (available since version 2.0.4)
Starts a batch query.
A batch query supports fetching data in batches, which can keep the memory usage under a limit. This method will return a yii\elasticsearch\BatchQueryResult object which implements the Iterator interface and can be traversed to retrieve the data in batches.
For example,
$query = (new Query)->from('user'); foreach ($query->batch() as $rows) { // $rows is an array of 10 or fewer rows from user table }
Batch size is determined by the limit
setting (note that in scan mode batch limit is per shard).
public yii\elasticsearch\BatchQueryResult batch ( $scrollWindow = '1m', $db = null ) | ||
---|---|---|
$scrollWindow | string |
How long Elasticsearch should keep the search context alive, in time units |
$db | yii\elasticsearch\Connection |
The database connection. If not set, the |
return | yii\elasticsearch\BatchQueryResult |
The batch query result. It implements the Iterator interface and can be traversed to retrieve the data in batches. |
Please login to continue.