Elastica\Client::bulk PHP Method

bulk() public method

Every entry in the params array has to exactly on array of the bulk operation. An example param array would be: array( array('index' => array('_index' => 'test', '_type' => 'user', '_id' => '1')), array('user' => array('name' => 'hans')), array('delete' => array('_index' => 'test', '_type' => 'user', '_id' => '2')) );
public bulk ( array $params ) : ResponseSet
$params array Parameter array
return Elastica\Bulk\ResponseSet Response object
    public function bulk(array $params)
    {
        if (empty($params)) {
            throw new InvalidException('Array has to consist of at least one param');
        }
        $bulk = new Bulk($this);
        $bulk->addRawData($params);
        return $bulk->send();
    }

Usage Example

 private function flushBulk()
 {
     $this->client->bulk($this->currentBulk);
     $this->currentBulkSize = 0;
     $this->currentBulk = [];
 }