public function SearchApiElasticsearchElastica::addIndex in Search API Elasticsearch 7
Overrides addIndex().
Overrides SearchApiAbstractService::addIndex
File
- modules/
elastica/ includes/ SearchApiElasticsearchElastica.inc, line 170 - Provides Elastica client for Search API Elasticsearch.
Class
- SearchApiElasticsearchElastica
- Search API Elasticsearch Elastica service class.
Code
public function addIndex(SearchApiIndex $index) {
$elastica_index = $this
->getElasticaIndex($index);
if (!empty($elastica_index)) {
try {
drupal_alter('search_api_elasticsearch_elastica_add_index', $index->options);
$response = $elastica_index
->create($index->options, TRUE);
} catch (Exception $e) {
watchdog('Elasticsearch', check_plain($e
->getMessage()), array(), WATCHDOG_ERROR);
drupal_set_message(check_plain($e
->getMessage()), 'error');
return FALSE;
}
// Update mapping.
$this
->fieldsUpdated($index);
}
}