You are here

function search_api_elasticsearch_elastica_search_api_index_reindex in Search API Elasticsearch 7

Implements hook_search_api_index_reindex. Since there is no way to put a mapping and settings on an index simultaneously, we allow users to delete and remap an index by using the clear index feature. This approximates the ElasticSearch recommendation to destroy and recreate indices to update their configuration.

File

modules/elastica/search_api_elasticsearch_elastica.module, line 211
Provides an elasticsearch-based service class for the Search API.

Code

function search_api_elasticsearch_elastica_search_api_index_reindex(SearchApiIndex $index, $clear = FALSE) {
  $server = search_api_index_get_server($index);

  // Only act on index provided by search_api_elasticsearch
  if ($clear && $server->class == "search_api_elasticsearch_elastica_service") {
    $server
      ->removeIndex($index);
    $server
      ->addIndex($index);
  }
}