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


PHP ClientBuilder::fromConfig方法代码示例

本文整理汇总了PHP中Elasticsearch\ClientBuilder::fromConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientBuilder::fromConfig方法的具体用法?PHP ClientBuilder::fromConfig怎么用?PHP ClientBuilder::fromConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Elasticsearch\ClientBuilder的用法示例。


在下文中一共展示了ClientBuilder::fromConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: registerElasticsearchClient

 /**
  * Register the Elasticsearch Client.
  *
  * @param array $config
  * @return void
  */
 protected function registerElasticsearchClient(array $config = [])
 {
     $this->app->bind(ElasticsearchClient::class, function () use($config) {
         return ElasticsearchClientBuilder::fromConfig($config);
     }, isset($config['singleton']) && $config['singleton']);
     $this->app->alias(ElasticsearchClient::class, $this->prefix());
 }
开发者ID:xian13,项目名称:laravel-elasticsearch,代码行数:13,代码来源:ServiceProvider.php

示例2: create

 /**
  * @param array $config
  *
  * @return Client
  */
 public function create(array $config)
 {
     if (class_exists('\\Elasticsearch\\ClientBuilder')) {
         return \Elasticsearch\ClientBuilder::fromConfig($config);
     }
     return new Client($config);
 }
开发者ID:mbadolato,项目名称:broadway,代码行数:12,代码来源:ElasticSearchClientFactory.php

示例3: getElasticSearchClient

 /**
  * Get ElasticSearch Client
  *
  * @return \Elasticsearch\Client
  */
 public function getElasticSearchClient()
 {
     $config = array();
     if (config()->has('elasticquent.config')) {
         $config = config()->get('elasticquent.config');
     }
     return \Elasticsearch\ClientBuilder::fromConfig($config);
 }
开发者ID:jclappiway,项目名称:Elasticquent,代码行数:13,代码来源:ElasticquentTrait.php

示例4: getElasticSearchClient

 /**
  * Get ElasticSearch Client
  *
  * @return \Elasticsearch\Client
  */
 public function getElasticSearchClient()
 {
     $config = array();
     if (\Config::has('elasticquent.config')) {
         $config = \Config::get('elasticquent.config');
     }
     return \Elasticsearch\ClientBuilder::fromConfig($config, true);
 }
开发者ID:pmcclelland,项目名称:Elasticquent,代码行数:13,代码来源:ElasticquentTrait.php

示例5: build

 /**
  * @return Client
  */
 public static function build($hosts)
 {
     $params = [];
     if (isset($hosts)) {
         $params['hosts'] = $hosts;
     }
     return ClientBuilder::fromConfig($params);
 }
开发者ID:theus77,项目名称:ElasticMS,代码行数:11,代码来源:ElasticsearchClientBuilderFactory.php

示例6: getElasticSearchClient

 /**
  * Get ElasticSearch Client
  *
  * @return \Elasticsearch\Client
  */
 public function getElasticSearchClient()
 {
     $config = $this->getElasticConfig();
     // elasticsearch v2.0 using builder
     if (class_exists('\\Elasticsearch\\ClientBuilder')) {
         return \Elasticsearch\ClientBuilder::fromConfig($config);
     }
     // elasticsearch v1
     return new \Elasticsearch\Client($config);
 }
开发者ID:mannysoft,项目名称:Elasticquent,代码行数:15,代码来源:ElasticquentClientTrait.php

示例7: getDriver

 /**
  * @return object
  */
 public function getDriver()
 {
     $config = $this->config->get('broadway.read-model-connections.elasticsearch.config');
     // elasticsearch v2.0 using builder
     if (class_exists(\Elasticsearch\ClientBuilder::class)) {
         return \Elasticsearch\ClientBuilder::fromConfig($config);
     }
     // elasticsearch v1
     return new \Elasticsearch\Client($config);
 }
开发者ID:Konafets,项目名称:Laravel-broadway,代码行数:13,代码来源:Elasticsearch.php

示例8: register

 /**
  * Register the Catalogue module service provider.
  *
  * This service provider is a convenient place to register your modules
  * services in the IoC container. If you wish, you may make additional
  * methods or service providers to keep the code more focused and granular.
  *
  * @throws \Elasticsearch\Common\Exceptions\RuntimeException
  *
  * @return void
  */
 public function register()
 {
     App::register('ChingShop\\Modules\\Catalogue\\Providers\\RouteServiceProvider');
     /* @noinspection RealpathOnRelativePathsInspection */
     View::addNamespace('catalogue', app_path('Modules/Catalogue/Resources/Views'));
     // Bind the Elasticsearch client to the container.
     $this->app->bind(Client::class, function () {
         return ElasticsearchBuilder::fromConfig(config('scout.elasticsearch.config'));
     });
 }
开发者ID:hughgrigg,项目名称:ching-shop,代码行数:21,代码来源:CatalogueServiceProvider.php

示例9: registerBindings

 /**
  * Register bindings.
  */
 protected function registerBindings()
 {
     /** @noinspection PhpUndefinedMethodInspection */
     $config = $this->app['config']->get('elasticsearch', []);
     $this->app->singleton(ElasticsearchServiceContract::class, function () use($config) {
         $elasticsearchService = new ElasticsearchService(ClientBuilder::fromConfig($config));
         if (isset($config[self::CONFIG_KEY]['settings'])) {
             $elasticsearchService->setSettings($config[self::CONFIG_KEY]['settings']);
         }
         return $elasticsearchService;
     });
 }
开发者ID:nordsoftware,项目名称:lumen-elasticsearch,代码行数:15,代码来源:ElasticsearchServiceProvider.php

示例10: _before

 /**
  * @inheritdoc
  */
 public function _before()
 {
     $service = new \Nord\Lumen\Elasticsearch\ElasticsearchService(\Elasticsearch\ClientBuilder::fromConfig([]));
     $queryBuilder = $service->createQueryBuilder();
     $this->search = $service->createSearch();
     $this->query = $queryBuilder->createBoolQuery();
     $this->query->addMust($queryBuilder->createTermQuery()->setField('field1')->setValue('value1'));
     $sortBuilder = $service->createSortBuilder();
     $this->sort = $service->createSort();
     $this->sort->addSort($sortBuilder->createScoreSort());
     $aggregationBuilder = $service->createAggregationBuilder();
     $this->aggregation = $aggregationBuilder->createGlobalAggregation();
     $this->aggregation->setName('global_name');
     $this->aggregation->addAggregation($aggregationBuilder->createMinAggregation()->setField('field_name')->setName('min_name'));
     $this->aggregation->addAggregation($aggregationBuilder->createMaxAggregation()->setField('field_name')->setName('max_name'));
 }
开发者ID:nordsoftware,项目名称:lumen-elasticsearch,代码行数:19,代码来源:SearchTest.php

示例11: testFromConfigBadParamQuiet

 public function testFromConfigBadParamQuiet()
 {
     $params = ['hosts' => ['localhost:9200'], 'retries' => 2, 'imNotReal' => 5];
     $client = ClientBuilder::fromConfig($params, true);
 }
开发者ID:avbrugen,项目名称:uace-laravel,代码行数:5,代码来源:ClientTest.php

示例12: createClient

 /**
  * Create a new ElasticSearch client instance.
  *
  * @param  array $config
  * @return \Elasticsearch\Client
  */
 protected function createClient($config)
 {
     // Use the Elasticsearch ClientBuilder helper to create the search client
     $config = $this->createLoggerConfig($config);
     return \Elasticsearch\ClientBuilder::fromConfig($config);
 }
开发者ID:elodex,项目名称:elodex,代码行数:12,代码来源:ElasticsearchClientManager.php

示例13: newClient

 /**
  * Create a new elastica client.
  *
  * @return Client
  */
 protected function newClient()
 {
     $config = config('elasticquent')['config'];
     if (class_exists('\\Elasticsearch\\ClientBuilder')) {
         return \Elasticsearch\ClientBuilder::fromConfig($config);
     }
     return new Client($this->connection());
 }
开发者ID:amrsoliman,项目名称:elasticquent,代码行数:13,代码来源:Laralastica.php

示例14: error_reporting

<?php

error_reporting(E_ALL | E_STRICT);
// Set the default timezone. While this doesn't cause any tests to fail, PHP
// complains if it is not set in 'date.timezone' of php.ini.
date_default_timezone_set('UTC');
// Ensure that composer has installed all dependencies
if (!file_exists(dirname(__DIR__) . '/composer.lock')) {
    die("Dependencies must be installed using composer:\n\nphp composer.phar install --dev\n\n" . "See http://getcomposer.org for help with installing composer\n");
}
// Include the composer autoloader
$autoloader = (require_once dirname(__DIR__) . '/vendor/autoload.php');
$client = \Elasticsearch\ClientBuilder::fromConfig(['hosts' => [$_SERVER['ES_TEST_HOST']]]);
$count = 0;
while (!$client->ping()) {
    $count += 1;
    if ($count > 15) {
        throw new \Exception("Live cluster could not be found in 15s!");
    }
    sleep(1);
}
开发者ID:howaichun,项目名称:elasticsearch-php,代码行数:21,代码来源:EnsureClusterAlive.php

示例15: createClient

 /**
  * Create a client instance from the ElasticSearch SDK.
  */
 public function createClient()
 {
     $client = ClientBuilder::fromConfig($this->environment->all());
     $this->setClient($client);
 }
开发者ID:madewithlove,项目名称:elasticsearcher,代码行数:8,代码来源:ElasticSearcher.php


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