You are here

protected function SearchApiElasticsearchBackend::getIndexId in Elasticsearch Connector 8

Same name and namespace in other branches
  1. 8.7 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::getIndexId()
  2. 8.2 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::getIndexId()
  3. 8.5 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::getIndexId()
  4. 8.6 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::getIndexId()

Prefixes an index ID as configured.

The resulting ID will be a concatenation of the following strings:

  • If set, the "elasticsearch.settings.index_prefix" configuration.
  • If set, the index-specific "elasticsearch.settings.index_prefix_INDEX" configuration.
  • The index's machine name.

Parameters

string $machine_name: The index's machine name.

Return value

string The prefixed machine name.

File

src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php, line 538
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 getIndexId($machine_name) {

  // Prepend per-index prefix.
  $id = $this->elasticsearchSettings
    ->get('index_prefix_' . $machine_name) . $machine_name;

  // Prepend environment prefix.
  $id = $this->elasticsearchSettings
    ->get('index_prefix') . $id;
  return $id;
}