You are here

function elasticsearch_connector_index_load in Elasticsearch Connector 7

Same name and namespace in other branches
  1. 7.5 elasticsearch_connector.module \elasticsearch_connector_index_load()
  2. 7.2 elasticsearch_connector.module \elasticsearch_connector_index_load()

Check if the index is valid and compare it with the indexes comming from Elasticsearch.

Parameters

string $index_name:

array $map_array:

int $index:

Return value

string|boolean

File

./elasticsearch_connector.module, line 234
This module provide an interface to connecting to the elasticsearch cluster and implementing the official Elasticsearch library.

Code

function elasticsearch_connector_index_load($index_name, $map_array, $index) {
  if (elasticsearch_connector_index_valid_load($index_name)) {
    $cluster = $map_array[4];
    $client = elasticsearch_connector_load_library($cluster);
    if (!empty($client)) {
      $indices = $client
        ->indices()
        ->stats();
      if (isset($indices['indices'][$index_name])) {
        return $index_name;
      }
      else {
        return FALSE;
      }
    }
  }
}