public static function IndexFactory::create in Elasticsearch Connector 8.5
Same name and namespace in other branches
- 8.7 src/ElasticSearch/Parameters/Factory/IndexFactory.php \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\IndexFactory::create()
- 8.2 src/ElasticSearch/Parameters/Factory/IndexFactory.php \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\IndexFactory::create()
- 8.6 src/ElasticSearch/Parameters/Factory/IndexFactory.php \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\IndexFactory::create()
Build parameters required to create an index TODO: Add the timeout option.
Parameters
\Drupal\search_api\IndexInterface $index:
Return value
array
File
- src/
ElasticSearch/ Parameters/ Factory/ IndexFactory.php, line 56
Class
- IndexFactory
- Create Elasticsearch Indices.
Namespace
Drupal\elasticsearch_connector\ElasticSearch\Parameters\FactoryCode
public static function create(IndexInterface $index) {
$indexName = IndexFactory::getIndexName($index);
$indexConfig = [
'index' => $indexName,
'body' => [
'settings' => [
'number_of_shards' => $index
->getOption('number_of_shards', 5),
'number_of_replicas' => $index
->getOption('number_of_replicas', 1),
],
],
];
// Allow other modules to alter index config before we create it.
$dispatcher = \Drupal::service('event_dispatcher');
$prepareIndexEvent = new PrepareIndexEvent($indexConfig, $indexName);
$event = $dispatcher
->dispatch(PrepareIndexEvent::PREPARE_INDEX, $prepareIndexEvent);
$indexConfig = $event
->getIndexConfig();
return $indexConfig;
}