You are here

public static function IndexFactory::getIndexName in Elasticsearch Connector 8.2

Same name and namespace in other branches
  1. 8.7 src/ElasticSearch/Parameters/Factory/IndexFactory.php \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\IndexFactory::getIndexName()
  2. 8.5 src/ElasticSearch/Parameters/Factory/IndexFactory.php \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\IndexFactory::getIndexName()
  3. 8.6 src/ElasticSearch/Parameters/Factory/IndexFactory.php \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\IndexFactory::getIndexName()

Helper function. Returns the elasticsearch name of an index.

Parameters

IndexInterface $index:

Return value

string

3 calls to IndexFactory::getIndexName()
IndexFactory::create in src/ElasticSearch/Parameters/Factory/IndexFactory.php
Build parameters required to create an index TODO: Add the timeout option.
IndexFactory::index in src/ElasticSearch/Parameters/Factory/IndexFactory.php
Build parameters required to index.
SearchApiElasticsearchBackend::addIndex in src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php
Adds a new index to this server.

File

src/ElasticSearch/Parameters/Factory/IndexFactory.php, line 164

Class

IndexFactory
Class IndexFactory.

Namespace

Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory

Code

public static function getIndexName(IndexInterface $index) {
  $options = \Drupal::database()
    ->getConnectionOptions();
  $site_database = $options['database'];
  $index_machine_name = is_string($index) ? $index : $index
    ->id();
  return preg_replace('/[^A-Za-z0-9_]+/', '', 'elasticsearch_index_' . $site_database . '_' . $index_machine_name);
}