本文整理汇总了PHP中Elasticsearch\Client::scroll方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::scroll方法的具体用法?PHP Client::scroll怎么用?PHP Client::scroll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elasticsearch\Client
的用法示例。
在下文中一共展示了Client::scroll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scanDocuments
/**
* Scan documents
*
* @param string $index
*/
protected function scanDocuments($index)
{
$params = ["search_type" => "scan", "scroll" => "50s", "size" => 50, "index" => $index, "body" => ["query" => ["match_all" => []]]];
$docs = $this->elasticsearch_client->search($params);
$scroll_id = $docs['_scroll_id'];
while (\true) {
$response = $this->elasticsearch_client->scroll(["scroll_id" => $scroll_id, "scroll" => "30s"]);
echo "<pre>";
print_r($response);
echo "</pre>";
die;
if (count($response['hits']['hits']) > 0) {
$scroll_id = $response['_scroll_id'];
} else {
break;
}
}
}
示例2: search
/**
* Search functionality exposed for use through the service provider.
* It uses scan search type and scroll API to retrieve large numbers of documents.
*
* @param array $indices The list of indices to include in the query. Defaults to searching all indices.
* @param array $types The list of types to include in the query. Defaults to searching all types.
* @param array $query The query to run against the specified indexes and types.
*
* @return array Like [
* 'total' => (integer), Number of documents returned by the query,
* 'hits' => [
* result set
* ],
* ];
*/
public function search(array $indices, array $types, array $query = [])
{
if (empty($indices)) {
$indices = ['_all'];
}
if ($types === null) {
$types = [];
}
$req = ['search_type' => 'scan', 'scroll' => '1m', 'index' => implode(',', $indices), 'type' => implode(',', $types), 'body' => $query];
$response = $this->client->search($req);
$scrollId = $response['_scroll_id'];
$totalResults['total'] = $response['hits']['total'];
$totalResults['hits'] = [];
do {
$totalResults['hits'] = array_merge($totalResults['hits'], $response['hits']['hits']);
$response = $this->client->scroll(['scroll_id' => $scrollId, 'scroll' => '1m']);
$results = $response['hits']['hits'];
$scrollId = $response['_scroll_id'];
} while (count($results) > 0);
return $totalResults;
}
示例3: next
/**
* Fetches every "page" after the first one using the latest "scroll_id"
*
* @return void
* @see Iterator::next()
*/
public function next()
{
$this->currentKey++;
$this->currentScrolledResponse = $this->client->scroll(array('scroll_id' => $this->scrollId, 'scroll' => $this->scrollTtl));
$this->scrollId = $this->currentScrolledResponse['_scroll_id'];
}
示例4: next
/**
* Fetches every "page" after the first one using the lastest "scroll_id"
*
* @return void
* @see Iterator::next()
*/
public function next()
{
$this->current_key++;
$this->current_scrolled_response = $this->client->scroll(array('scroll_id' => $this->scroll_id, 'scroll' => $this->scroll_ttl));
$this->scroll_id = $this->current_scrolled_response['_scroll_id'];
}