當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Client::updateDocuments方法代碼示例

本文整理匯總了PHP中Elastica\Client::updateDocuments方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::updateDocuments方法的具體用法?PHP Client::updateDocuments怎麽用?PHP Client::updateDocuments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Elastica\Client的用法示例。


在下文中一共展示了Client::updateDocuments方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: batchUpdate

 /**
  * @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
     }
 }
開發者ID:jiangyu7408,項目名稱:notification,代碼行數:38,代碼來源:ElasticaHelper.php

示例2: updateDocuments

 /**
  * 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);
 }
開發者ID:phpfour,項目名稱:ah,代碼行數:16,代碼來源:Elastica.php


注:本文中的Elastica\Client::updateDocuments方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。