You are here

public function Apache_Solr_Service::commit in Apache Solr Search 5

Send a commit command. Will be synchronous unless both wait parameters are set to false.

Parameters

boolean $optimize Defaults to true:

boolean $waitFlush Defaults to true:

boolean $waitSearcher Defaults to true:

float $timeout Maximum expected duration (in seconds) of the commit operation on the server (otherwise, will throw a communication exception). Defaults to 1 hour:

Return value

Apache_Solr_Response

Throws

Exception If an error occurs during the service call

File

SolrPhpClient/Apache/Solr/Service.php, line 751

Class

Apache_Solr_Service
Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching.

Code

public function commit($optimize = true, $waitFlush = true, $waitSearcher = true, $timeout = 3600) {
  $optimizeValue = $optimize ? 'true' : 'false';
  $flushValue = $waitFlush ? 'true' : 'false';
  $searcherValue = $waitSearcher ? 'true' : 'false';
  $rawPost = '<commit optimize="' . $optimizeValue . '" waitFlush="' . $flushValue . '" waitSearcher="' . $searcherValue . '" />';
  return $this
    ->_sendRawPost($this->_updateUrl, $rawPost, $timeout);
}