SolrCommitTrait.php in Search API Solr 8.2
File
src/Utility/SolrCommitTrait.php
View source
<?php
namespace Drupal\search_api_solr\Utility;
use Drupal\search_api\ServerInterface;
defined('SOLR_INDEX_WAIT') || define('SOLR_INDEX_WAIT', getenv('SOLR_INDEX_WAIT') ?: 0);
trait SolrCommitTrait {
protected function ensureCommit(ServerInterface $server) {
$backend = $server
->getBackend();
$connector = $backend
->getSolrConnector();
$update = $connector
->getUpdateQuery();
$update
->addCommit(TRUE, TRUE, TRUE);
$connector
->update($update);
if (SOLR_INDEX_WAIT) {
sleep(SOLR_INDEX_WAIT);
}
}
}