You are here

public function StandardSolrConnector::reloadCore in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 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();
  $this
    ->useTimeout(self::INDEX_TIMEOUT);
  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);
  }
}