當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。