本文整理汇总了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
}
}
示例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);
}