You are here

public static function IndexFactory::getIndexName in Elasticsearch Connector 8.5

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.2 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

\Drupal\search_api\IndexInterface $index: Index object.

Return value

string The name of the index on the Elasticsearch server. Includes a prefix for uniqueness, the database name, and index machine name.

4 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.
SearchBuilder::build in src/ElasticSearch/Parameters/Builder/SearchBuilder.php
Build up the body of the request to the Elasticsearch _search endpoint.
SearchBuilder::getSearchQueryOptions in src/ElasticSearch/Parameters/Builder/SearchBuilder.php
Helper function to return associative array with query options.

File

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

Class

IndexFactory
Create Elasticsearch Indices.

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 strtolower(preg_replace('/[^A-Za-z0-9_]+/', '', 'elasticsearch_index_' . $site_database . '_' . $index_machine_name));
}