silverstripe-fulltextsearch/code/solr/Solr4Service.php
Hamish Friedlander 3d18903552 API Add support for Solr 4 and make it the default
Solr::configure_server now takes "version" as one of the keys in the
option array, and behaves slightly differently depending on whether
that version is 3 or 4, to provide support for both Solr versions.

The Solr extras and templates have also moved, so that different
versions can be provided for the two different Solr versions.
2013-11-08 15:03:47 +13:00

26 lines
799 B
PHP

<?php
class Solr4Service_Core extends SolrService_Core {
/**
* Replace underlying commit function to remove waitFlush in 4.0+, since it's been deprecated and 4.4 throws errors
* if you pass it
*/
public function commit($expungeDeletes = false, $waitFlush = null, $waitSearcher = true, $timeout = 3600) {
if ($waitFlush) {
user_error('waitFlush must be false when using Solr 4.0+' . E_USER_ERROR);
}
$expungeValue = $expungeDeletes ? 'true' : 'false';
$searcherValue = $waitSearcher ? 'true' : 'false';
$rawPost = '<commit expungeDeletes="' . $expungeValue . '" waitSearcher="' . $searcherValue . '" />';
return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout);
}
}
class Solr4Service extends SolrService {
private static $core_class = 'Solr4Service_Core';
}