You are here

protected function SearchApiElasticsearchBackend::connect in Elasticsearch Connector 8

Creates a connection to the Elasticsearch server as configured in $this->configuration.

8 calls to SearchApiElasticsearchBackend::connect()
SearchApiElasticsearchBackend::addIndex in src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php
Overrides addIndex().
SearchApiElasticsearchBackend::deleteItemsIds in src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php
Helper function for bulk delete operation.
SearchApiElasticsearchBackend::fieldsUpdated in src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php
Overrides fieldsUpdated().
SearchApiElasticsearchBackend::getElasticsearchTypeExists in src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php
Helper function, check if the type exists.
SearchApiElasticsearchBackend::indexItems in src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php
Overrides indexItems().

... See full list

File

src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php, line 167
Contains the SearchApiElasticsearchBackend object.

Class

SearchApiElasticsearchBackend
Plugin annotation @SearchApiBackend( id = "elasticsearch", label = @Translation("Elasticsearch"), description = @Translation("Index items using an Elasticsearch server.") )

Namespace

Drupal\elasticsearch_connector\Plugin\search_api\backend

Code

protected function connect() {
  if (!$this->elasticsearchClient && $this->configuration) {
    if (empty($this->configuration['cluster_settings']['cluster'])) {
      $cluster = Cluster::getDefaultCluster();
    }
    else {
      $cluster = $this->configuration['cluster_settings']['cluster'];
    }
    $this->clusterEntity = Cluster::load($cluster);
    $this->elasticsearchClient = Cluster::getClientInstance($this->clusterEntity);
  }
}