You are here

public function StandardSolrConnector::reloadCore in Search API Solr 8.3

Same name and namespace in other branches
  1. 4.x src/Plugin/SolrConnector/StandardSolrConnector.php \Drupal\search_api_solr\Plugin\SolrConnector\StandardSolrConnector::reloadCore()

Reloads the Solr core.

Return value

bool TRUE if successful, FALSE otherwise.

Throws

\Drupal\search_api_solr\SearchApiSolrException

Overrides SolrConnectorInterface::reloadCore

1 method overrides StandardSolrConnector::reloadCore()
StandardSolrCloudConnector::reloadCore in src/Plugin/SolrConnector/StandardSolrCloudConnector.php
Reloads the Solr core.

File

src/Plugin/SolrConnector/StandardSolrConnector.php, line 23

Class

StandardSolrConnector
Standard Solr connector.

Namespace

Drupal\search_api_solr\Plugin\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);
    return $response
      ->getWasSuccessful();
  } catch (HttpException $e) {
    throw new SearchApiSolrException("Reloading core {$core} failed with error code " . $e
      ->getCode() . '.', $e
      ->getCode(), $e);
  }
}