You are here

protected function SearchApiSolrConnection::optimizeOrCommit in Search API Solr 7

Sends a commit or optimize command to the Solr server.

Will be synchronous unless $waitSearcher is set to FALSE.

Parameters

string $type: Either "commit" or "optimize".

bool $waitSearcher: (optional) Wait until a new searcher is opened and registered as the main query searcher, making the changes visible. Defaults to true.

int $timeout: Seconds to wait until timing out with an exception. Defaults to an hour.

Return value

object A response object.

Throws

SearchApiException If an error occurs during the service call.

2 calls to SearchApiSolrConnection::optimizeOrCommit()
SearchApiSolrConnection::commit in includes/solr_connection.inc
Sends a commit command to the Solr server.
SearchApiSolrConnection::optimize in includes/solr_connection.inc
Sends an optimize command to the Solr server.

File

includes/solr_connection.inc, line 863

Class

SearchApiSolrConnection
Represents a Solr server resource.

Code

protected function optimizeOrCommit($type, $waitSearcher = TRUE, $timeout = 3600) {
  $waitSearcher = $waitSearcher ? '' : ' waitSearcher="false"';
  if ($this
    ->getSolrVersion() <= 3) {
    $rawPost = "<{$type}{$waitSearcher} />";
  }
  else {
    $softCommit = $this->soft_commit ? ' softCommit="true"' : '';
    $rawPost = "<{$type}{$waitSearcher}{$softCommit} />";
  }
  $response = $this
    ->update($rawPost, $timeout);
  $this
    ->clearCache();
  return $response;
}