当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::scroll方法代码示例

本文整理汇总了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;
         }
     }
 }
开发者ID:triadev,项目名称:silex-scope-framework,代码行数:23,代码来源:AbstractElasticsearchClient.php

示例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;
 }
开发者ID:Code4HR,项目名称:hercules,代码行数:36,代码来源:ElasticSearchServiceProvider.php

示例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'];
 }
开发者ID:CascadeEnergy,项目名称:php-elasticsearch,代码行数:12,代码来源:SearchResponseIterator.php

示例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'];
 }
开发者ID:arturom,项目名称:index-dash,代码行数:12,代码来源:SearchResponseIterator.php


注:本文中的Elasticsearch\Client::scroll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。