You are here

protected function SearchApiElasticsearchBackend::getElasticsearchTypeExists in Elasticsearch Connector 8

Helper function, check if the type exists.

Parameters

IndexInterface $index:

Return value

boolean

1 call to SearchApiElasticsearchBackend::getElasticsearchTypeExists()
SearchApiElasticsearchBackend::indexItems in src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php
Overrides indexItems().

File

src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php, line 457
Contains the SearchApiElasticsearchBackend object.

Class

SearchApiElasticsearchBackend
Plugin annotation @SearchApiBackend( id = "elasticsearch", label = @Translation("Elasticsearch"), description = @Translation("Index items using an Elasticsearch server.") )

Namespace

Drupal\elasticsearch_connector\Plugin\search_api\backend

Code

protected function getElasticsearchTypeExists(IndexInterface $index) {
  $this
    ->connect();
  $params = $this
    ->getIndexParam($index, TRUE);
  try {
    return $this->elasticsearchClient
      ->getIndices()
      ->existsType($params);
  } catch (\Exception $e) {
    drupal_set_message($e
      ->getMessage(), 'error');
    return FALSE;
  }
}