You are here

search_api_elasticsearch.install in Search API Elasticsearch 7

Same filename and directory in other branches
  1. 7.2 search_api_elasticsearch.install

Install/Uninstall/Update tasks for the Search API Elasticsearch module.

File

search_api_elasticsearch.install
View source
<?php

/**
 * @file
 * Install/Uninstall/Update tasks for the Search API Elasticsearch module.
 */

/**
 * Upgrade to multiple client support and convert settings.
 */
function search_api_elasticsearch_update_7101() {
  module_load_include('module', 'search_api');

  // Disable Search API servers.
  foreach (search_api_server_load_multiple(FALSE, array(
    'class' => 'search_api_elasticsearch_service',
  ), TRUE) as $server) {
    $server
      ->update(array(
      'enabled' => 0,
    ));
  }

  // Enable Search API Elasticsearch Elastica.
  module_enable(array(
    'search_api_elasticsearch_elastica',
  ));

  // Update Search API servers to use the new class
  foreach (search_api_server_load_multiple(FALSE, array(
    'class' => 'search_api_elasticsearch_service',
  ), TRUE) as $server) {
    $server->class = 'search_api_elasticsearch_elastica_service';
    $server
      ->save();
  }

  // Enable Search API servers.
  foreach (search_api_server_load_multiple(FALSE, array(
    'class' => 'search_api_elasticsearch_elastica_service',
  ), TRUE) as $server) {
    $server
      ->update(array(
      'enabled' => 1,
    ));
  }
}

Functions

Namesort descending Description
search_api_elasticsearch_update_7101 Upgrade to multiple client support and convert settings.