You are here

public function SearchApiElasticsearchElastica::removeIndex in Search API Elasticsearch 7

Overrides removeIndex().

Overrides SearchApiAbstractService::removeIndex

File

modules/elastica/includes/SearchApiElasticsearchElastica.inc, line 230
Provides Elastica client for Search API Elasticsearch.

Class

SearchApiElasticsearchElastica
Search API Elasticsearch Elastica service class.

Code

public function removeIndex($index) {
  $elastica_index = $this
    ->getElasticaIndex($index);

  // PATCH - Only delete the index's data if the index isn't read-only.
  if (!empty($elastica_index) && $index->read_only != 1) {
    try {
      $response = $elastica_index
        ->delete();
      return $response;
    } catch (Exception $e) {
      watchdog('Elasticsearch', check_plain($e
        ->getMessage()), array(), WATCHDOG_ERROR);
      drupal_set_message(check_plain($e
        ->getMessage()), 'error');
      return FALSE;
    }
  }
}