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