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


PHP Client::getIndex方法代码示例

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


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

示例1: initialize

 /**
  * До любых других действий
  */
 public function initialize()
 {
     $currentActionName = $this->dispatcher->getActiveMethod();
     $annotations = $this->annotations->getMethod(self::class, $currentActionName);
     if ($annotations->has('actionInfo')) {
         $annotation = $annotations->get('actionInfo');
         $actionTitle = $annotation->getNamedArgument('name');
         $this->log->info('Запустили: {actionTitle}', ['actionTitle' => $actionTitle]);
     } else {
         $currentTaskName = $this->dispatcher->getTaskName();
         $this->log->info('Запустили: {currentTaskName}::{currentActionName}', ['currentTaskName' => $currentTaskName, 'currentActionName' => $currentActionName]);
     }
     $this->indexName = $this->dispatcher->getParam('index', 'string', false);
     $this->typeName = $this->dispatcher->getParam('type', 'string', false);
     if (!$this->indexName) {
         $this->log->error('Указание индекса является обязательным параметром');
         die;
     }
     $this->sizePerShard = $this->dispatcher->getParam('sizePerShard', 'int', false) ?: $this->sizePerShard;
     $this->elasticsearchHost = $this->dispatcher->getParam('host', 'string', false) ?: $this->elasticsearchHost;
     $this->elasticsearchPort = $this->dispatcher->getParam('port', 'int', false) ?: $this->elasticsearchPort;
     $connectParams = ['host' => $this->elasticsearchHost, 'port' => $this->elasticsearchPort];
     $this->client = new Client($connectParams);
     try {
         $this->client->getStatus();
     } catch (\Elastica\Exception\Connection\HttpException $e) {
         $context = ['host' => $this->elasticsearchHost, 'port' => $this->elasticsearchPort];
         $this->log->error('Подключение к серверу elasticsearch отсутствует: http://{host}:{port}', $context);
         die;
     }
     $this->elasticaIndex = $this->client->getIndex($this->indexName);
     $this->elasticaType = $this->elasticaIndex->getType($this->typeName);
 }
开发者ID:mzf,项目名称:phalcon-php-elasticsearch-backup,代码行数:36,代码来源:elasticsearch-dumper.php

示例2: persist

 /**
  * @param array $payload
  *
  * @return bool
  */
 public function persist(array $payload)
 {
     $documents = array_map(function (array $user) {
         return $this->makeDocument($user);
     }, $payload);
     $responseSet = $this->elasticaClient->getIndex($this->target->index)->addDocuments($documents);
     $this->responses = $responseSet;
     return true;
 }
开发者ID:jiangyu7408,项目名称:notification,代码行数:14,代码来源:GatewayUserPersist.php

示例3: __construct

 /**
  * @param array $options
  */
 public function __construct($options = [])
 {
     parent::__construct($options);
     $this->client = new Client($options);
     if (!isset($options['index'])) {
         $options['index'] = 'log';
     }
     $this->index = $this->client->getIndex($options['index']);
 }
开发者ID:hayloft,项目名称:zend-log-elastic,代码行数:12,代码来源:Elastic.php

示例4: getIndex

 /**
  * @return Index
  */
 private function getIndex()
 {
     if (null === $this->index) {
         $this->index = $this->client->getIndex($this->indexName);
         if (!$this->index->exists()) {
             $this->index->create();
         }
     }
     return $this->index;
 }
开发者ID:basster,项目名称:doctrine-elastica-cache,代码行数:13,代码来源:Cache.php

示例5: createIndex

 /**
  * @param \Generated\Shared\Transfer\ElasticsearchIndexDefinitionTransfer $indexDefinitionTransfer
  *
  * @return void
  */
 protected function createIndex(ElasticsearchIndexDefinitionTransfer $indexDefinitionTransfer)
 {
     $index = $this->elasticaClient->getIndex($indexDefinitionTransfer->getIndexName());
     if (!$index->exists()) {
         $this->messenger->info(sprintf('Creating elasticsearch index: "%s"', $indexDefinitionTransfer->getIndexName()));
         $settings = $indexDefinitionTransfer->getSettings();
         $index->create($settings);
     }
     foreach ($indexDefinitionTransfer->getMappings() as $mappingName => $mappingData) {
         $this->sendMapping($index, $mappingName, $mappingData);
     }
 }
开发者ID:spryker,项目名称:Search,代码行数:17,代码来源:IndexInstaller.php

示例6: indexExtension

 /**
  * @var Extension
  * @var bool
  */
 public function indexExtension(Extension $extension, $update = false)
 {
     $id = $extension->getName();
     $packageDocument = new \Elastica\Document($id, ['id' => $id, 'name' => $id, 'description' => $extension->getDescription(), 'tags' => $extension->getVersions(), 'keywords' => $extension->getKeywords(), 'stars' => $extension->getStars()]);
     $elasticaIndex = $this->client->getIndex('packages');
     $elasticaType = $elasticaIndex->getType('packages');
     if ($update) {
         $elasticaType->updateDocument($packageDocument);
     } else {
         $elasticaType->addDocument($packageDocument);
     }
     $elasticaType->getIndex()->refresh();
 }
开发者ID:Doanlmit,项目名称:pickleweb,代码行数:17,代码来源:Indexer.php

示例7: __construct

 public function __construct($options, $indexName, $typeName)
 {
     if ($this->client) {
         return $this->client;
     }
     if ($options['debug']) {
         define('DEBUG', true);
     }
     $this->host = $options['host'];
     $this->port = $options['port'];
     $this->client = new \Elastica\Client(['host' => $this->host, 'port' => $this->port]);
     $this->index = $this->client->getIndex($indexName);
     $this->indexName = $indexName;
     $this->typeName = $typeName;
 }
开发者ID:anmoroz,项目名称:yii2-analytics,代码行数:15,代码来源:ElasticaBase.php

示例8: newIndex

 /**
  * Get the elasticsearch index being used.
  *
  * @return Index
  */
 protected function newIndex()
 {
     if (!isset($this->client)) {
         $this->client = $this->newClient();
     }
     return $this->client->getIndex($this->config['index']);
 }
开发者ID:amrsoliman,项目名称:laralastica,代码行数:12,代码来源:Laralastica.php

示例9: publish

 public function publish(Client $client, $actionType, TableInterface $table, RecordInterface $record)
 {
     $con = new Condition(array('id', '=', $record->id));
     $row = $table->getRow(array('id', 'pageId', 'userId', 'urlTitle', 'title', 'text'), $con);
     $index = $client->getIndex('amun');
     $type = $index->getType('page');
     $id = $row['pageId'] . '-' . $record->id;
     try {
         $document = $type->getDocument($id);
         if ($actionType == RecordAbstract::INSERT || $actionType == RecordAbstract::UPDATE) {
             // get referring page
             $handler = $this->hm->getHandler('AmunService\\Content\\Page');
             $page = $handler->get($row['pageId'], array('id', 'path', 'urlTitle', 'title'));
             $data = array('id' => $id, 'userId' => $row['userId'], 'path' => $page['path'] . '/view/' . $row['id'] . '/' . $row['urlTitle'], 'title' => $row['title'], 'content' => $row['text'], 'date' => time());
             $type->updateDocument(new Document($id, $data));
         } else {
             if ($actionType == RecordAbstract::DELETE) {
                 $type->deleteDocument($document);
             }
         }
     } catch (NotFoundException $e) {
         if ($actionType == RecordAbstract::INSERT || $actionType == RecordAbstract::UPDATE) {
             // get referring page
             $handler = $this->hm->getHandler('AmunService\\Content\\Page');
             $page = $handler->get($row['pageId'], array('id', 'path', 'urlTitle', 'title'));
             $data = array('id' => $id, 'userId' => $row['userId'], 'path' => $page['path'] . '/view/' . $row['id'] . '/' . $row['urlTitle'], 'title' => $row['title'], 'content' => $row['text'], 'date' => time());
             $type->addDocument(new Document($id, $data));
         } else {
             if ($actionType == RecordAbstract::DELETE) {
                 // is already deleted
             }
         }
     }
     $type->getIndex()->refresh();
 }
开发者ID:visapi,项目名称:amun,代码行数:35,代码来源:SearchIndexer.php

示例10: handle

 /**
  * Handle index creation command
  *
  * @param Client $client
  * @param string $index
  * @param string $alias
  */
 public function handle(Client $client, $index, $alias)
 {
     $settings = $this->configurations->getSettings($alias);
     if (null === $settings) {
         throw new \InvalidArgumentException();
     }
     $client->getIndex($index)->setSettings($settings);
 }
开发者ID:gbprod,项目名称:elastica-extra-bundle,代码行数:15,代码来源:PutIndexSettingsHandler.php

示例11: handle

 /**
  * Handle index creation command
  *
  * @param Client $client
  * @param string $index
  * @param string $alias
  */
 public function handle(Client $client, $index, $alias)
 {
     $config = $this->configurations->get($alias);
     if (null === $config) {
         throw new \InvalidArgumentException();
     }
     $client->getIndex($index)->create($config);
 }
开发者ID:gbprod,项目名称:elastica-extra-bundle,代码行数:15,代码来源:CreateIndexHandler.php

示例12: addDocumentsToPlayListIndex

 /**
  * @param $documents
  */
 protected function addDocumentsToPlayListIndex($documents)
 {
     $elasticaClient = new Client();
     $playListIndex = $elasticaClient->getIndex('track_index');
     $trackType = $playListIndex->getType('track');
     $trackType->addDocuments($documents);
     $trackType->getIndex()->refresh();
 }
开发者ID:slaparra,项目名称:Training-Elastic-Search-Symfony,代码行数:11,代码来源:ImportTracksFromDbToTrackIndexCommand.php

示例13: handle

 /**
  * Handle index deletion command
  *
  * @param Client $client
  * @param string $index
  *
  * @throws IndexNotFoundException
  */
 public function handle(Client $client, $index)
 {
     $index = $client->getIndex($index);
     if (!$index->exists()) {
         throw new IndexNotFoundException($index);
     }
     $index->delete();
 }
开发者ID:gbprod,项目名称:elastica-extra-bundle,代码行数:16,代码来源:DeleteIndexHandler.php

示例14: handle

 /**
  * Handle index creation command
  *
  * @param Client $client
  * @param string $index
  * @param string $type
  * @param string $alias
  */
 public function handle(Client $client, $index, $type, $alias)
 {
     $mapping = $this->configurations->getMapping($alias, $type);
     if (!$mapping) {
         throw new \InvalidArgumentException();
     }
     $client->getIndex($index)->getType($type)->setMapping($mapping);
 }
开发者ID:gbprod,项目名称:elastica-extra-bundle,代码行数:16,代码来源:PutIndexMappingsHandler.php

示例15: getIndexByAlias

 /**
  * @return Index
  * @throws ElasticaManagerIndexNotFoundException
  */
 public function getIndexByAlias()
 {
     $defaultAlias = $this->getDefaultAlias();
     if (!$this->hasAlias($defaultAlias)) {
         throw new ElasticaManagerIndexNotFoundException($defaultAlias, true);
     }
     $elasticaIndex = $this->client->getIndex($defaultAlias);
     return $elasticaIndex;
 }
开发者ID:darklow,项目名称:ff-elastica-manager,代码行数:13,代码来源:IndexManager.php


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