public function DrupalApacheSolrService::optimize in Apache Solr Search 7
Same name and namespace in other branches
- 8 Drupal_Apache_Solr_Service.php \DrupalApacheSolrService::optimize()
- 6.3 Drupal_Apache_Solr_Service.php \DrupalApacheSolrService::optimize()
Send an optimize command. Will be synchronous unless both wait parameters are set to false.
Parameters
boolean $waitFlush: block until index changes are flushed to disk Removed in Solr 4.0
boolean $waitSearcher: block until a new searcher is opened and registered as the main query searcher, making the changes visible.
float $timeout: Maximum expected duration of the commit operation on the server (otherwise, will throw a communication exception)
Return value
response object
Throws
Exception If an error occurs during the service call
Overrides DrupalApacheSolrServiceInterface::optimize
File
- ./
Drupal_Apache_Solr_Service.php, line 864
Class
- DrupalApacheSolrService
- 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 optimize($waitFlush = TRUE, $waitSearcher = TRUE, $timeout = 3600) {
$flushValue = $waitFlush ? 'true' : 'false';
$searcherValue = $waitSearcher ? 'true' : 'false';
$softCommit = $this->soft_commit ? 'true' : 'false';
$solr_version = $this
->getSolrVersion();
if ($solr_version <= 3) {
$rawPost = '<optimize waitSearcher="' . $searcherValue . '" waitFlush="' . $flushValue . '" />';
}
else {
$rawPost = '<optimize waitSearcher="' . $searcherValue . '" softCommit="' . $softCommit . '" />';
}
return $this
->update($rawPost, $timeout);
}