本文整理汇总了PHP中Elastica\Client::addDocuments方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::addDocuments方法的具体用法?PHP Client::addDocuments怎么用?PHP Client::addDocuments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elastica\Client
的用法示例。
在下文中一共展示了Client::addDocuments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bulkSend
/**
* Use Elasticsearch bulk API to send list of documents
* @param array $documents
* @throws \RuntimeException
*/
protected function bulkSend(array $documents)
{
try {
$this->client->addDocuments($documents);
} catch (ExceptionInterface $e) {
if (!$this->options['ignore_error']) {
throw new \RuntimeException("Error sending messages to Elasticsearch", 0, $e);
}
}
}
示例2: addDocuments
/**
* 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 addDocuments(array $docs)
{
return $this->client->addDocuments($docs);
}