Smile\ElasticsuiteCore\Api\Index\Bulk\BulkRequestInterface::getOperations PHP Метод

getOperations() публичный Метод

Return list of operations to be executed as an array.
public getOperations ( ) : array
Результат array
    public function getOperations();

Usage Example

Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function executeBulk(BulkRequestInterface $bulk)
 {
     $bulkParams = ['body' => $bulk->getOperations()];
     $rawBulkResponse = $this->client->bulk($bulkParams);
     /**
      * @var BulkResponseInterface
      */
     $bulkResponse = $this->objectManager->create('Smile\\ElasticsuiteCore\\Api\\Index\\Bulk\\BulkResponseInterface', ['rawResponse' => $rawBulkResponse]);
     if ($bulkResponse->hasErrors()) {
         foreach ($bulkResponse->aggregateErrorsByReason() as $error) {
             $sampleDocumentIds = implode(', ', array_slice($error['document_ids'], 0, 10));
             $errorMessages = [sprintf("Bulk %s operation failed %d times in index %s for type %s", $error['operation'], $error['count'], $error['index'], $error['document_type']), sprintf("Error (%s) : %s", $error['error']['type'], $error['error']['reason']), sprintf("Failed doc ids sample : %s", $sampleDocumentIds)];
             $this->logger->error(implode(" ", $errorMessages));
         }
     }
     return $bulkResponse;
 }