You are here

public function StandardSolrCloudConnector::uploadConfigset in Search API Solr 4.x

Upload a configset to Solr Cloud

Parameters

string $name: The name of the configset within Solr

string $filename: The file name of the configset to uplaod.

Return value

bool

Throws

\Drupal\search_api_solr\SearchApiSolrException

Overrides SolrCloudConnectorInterface::uploadConfigset

File

src/Plugin/SolrConnector/StandardSolrCloudConnector.php, line 237

Class

StandardSolrCloudConnector
Standard Solr Cloud connector.

Namespace

Drupal\search_api_solr\Plugin\SolrConnector

Code

public function uploadConfigset(string $name, string $filename) : bool {
  $this
    ->connect();
  $this
    ->useTimeout(self::FINALIZE_TIMEOUT);
  try {
    $configsetsQuery = $this->solr
      ->createConfigsets();
    $action = $configsetsQuery
      ->createUpload();
    $action
      ->setFile($filename)
      ->setName($name)
      ->setOverwrite(true);
    $configsetsQuery
      ->setAction($action);
    $response = $this->solr
      ->configsets($configsetsQuery);
    return $response
      ->getWasSuccessful();
  } catch (HttpException $e) {
    throw new SearchApiSolrException(sprintf('Configset upload failed with error code %s: %s', $e
      ->getCode(), $e
      ->getMessage()), $e
      ->getCode(), $e);
  }
}