updateDocuments() public méthode

Array of \Elastica\Document as input. Index and type has to be set inside the document, because for bulk settings documents, documents can belong to any type and index
public updateDocuments ( array $docs ) : ResponseSet
$docs array Array of Elastica\Document
Résultat Elastica\Bulk\ResponseSet Response object
 /**
  * @param Document[] $documents
  * @param Closure    $errorHandler
  */
 protected function batchUpdate(array $documents, Closure $errorHandler)
 {
     $count = count($documents);
     if ($count === 0) {
         return;
     }
     if ($this->verbose) {
         array_map(function (Document $document) {
             $data = $document->getData();
             dump($data);
         }, $documents);
     }
     $this->validateFields($documents);
     try {
         $responseSet = $this->elastica->updateDocuments($documents);
         $failedSnsidList = [];
         $versionList = [];
         foreach ($responseSet as $response) {
             $this->parseResponse($response, $failedSnsidList, $versionList);
         }
         if ($failedSnsidList) {
             call_user_func($errorHandler, $failedSnsidList);
         }
         if (is_callable($this->versionHandler)) {
             call_user_func($this->versionHandler, $versionList);
         }
     } catch (\Exception $exception) {
         if (is_callable($this->errorHandler)) {
             call_user_func($this->errorHandler, $exception);
         }
         $this->elastica = $this->makeElastica();
         // Try to keep going on updating
     }
 }
Exemple #2
0
 /**
  * Uses _bulk to send documents to the server.
  *
  * Array of \Elastica\Document as input. Index and type has to be
  * set inside the document, because for bulk settings documents,
  * documents can belong to any type and index
  *
  * @param  array|\Elastica\Document[]           $docs Array of Elastica\Document
  * @return \Elastica\Bulk\ResponseSet           Response object
  * @throws \Elastica\Exception\InvalidException If docs is empty
  * @link http://www.elasticsearch.org/guide/reference/api/bulk.html
  */
 public function updateDocuments(array $docs)
 {
     return $this->client->updateDocuments($docs);
 }