You are here

public function SolrConnectorPluginBase::reloadCore in Search API Solr 8.2

Reloads the Solr core.

Return value

bool

Overrides SolrConnectorInterface::reloadCore

File

src/SolrConnector/SolrConnectorPluginBase.php, line 1032

Class

SolrConnectorPluginBase
Defines a base class for Solr connector plugins.

Namespace

Drupal\search_api_solr\SolrConnector

Code

public function reloadCore() {
  $this
    ->connect();
  try {
    $core = $this->configuration['core'];
    $core_admin_query = $this->solr
      ->createCoreAdmin();
    $reload_action = $core_admin_query
      ->createReload();
    $reload_action
      ->setCore($core);
    $core_admin_query
      ->setAction($reload_action);
    $response = $this->solr
      ->coreAdmin($core_admin_query);
    $was_successful = $response
      ->getWasSuccessful();
    return $was_successful;
  } catch (HttpException $e) {
    throw new SearchApiSolrException("Reloading core {$core} failed with error code " . $e
      ->getCode() . '.', $e
      ->getCode(), $e);
  }
}