You are here

protected function SearchApiElasticsearchConnectorStats::createStatsIndex in Elasticsearch Connector 7.5

Create Elasticsearch connector search api statistics type.

Parameters

array $params: The index name and the type name for the index creation.

Return value

array Result of the create index execution.

Throws

\Exception

1 call to SearchApiElasticsearchConnectorStats::createStatsIndex()
SearchApiElasticsearchConnectorStats::logStat in modules/elasticsearch_connector_search_api/includes/elasticsearch_stats.inc
Logging the statistics into the stats type in elasticsearch index.

File

modules/elasticsearch_connector_search_api/includes/elasticsearch_stats.inc, line 138
@author nikolayignatov

Class

SearchApiElasticsearchConnectorStats

Code

protected function createStatsIndex($params) {
  $client = $this->connector
    ->getConnectorObject();
  $index_params = array(
    'index' => $params['index'],
    'body' => array(
      'settings' => array(
        'number_of_shards' => !empty($this->index->options['index_statistics_num_of_shards']) ? $this->index->options['index_statistics_num_of_shards'] : self::NUM_OF_SHARDS,
        'number_of_replicas' => !empty($this->index->options['index_statistics_num_of_replicas']) ? $this->index->options['index_statistics_num_of_replicas'] : self::NUM_OF_REPLICAS,
      ),
      'mappings' => array(
        $params['type'] => $this
          ->getStatsMapping(),
      ),
    ),
  );
  try {
    return $client
      ->indices()
      ->create($index_params);
  } catch (Exception $e) {
    throw $e;
  }
}