trait SolrCommitTrait in Search API Solr 4.x
Same name and namespace in other branches
- 8.3 src/Utility/SolrCommitTrait.php \Drupal\search_api_solr\Utility\SolrCommitTrait
- 8 src/Utility/SolrCommitTrait.php \Drupal\search_api_solr\Utility\SolrCommitTrait
- 8.2 src/Utility/SolrCommitTrait.php \Drupal\search_api_solr\Utility\SolrCommitTrait
Helper to ensure that solr index is up to date.
Hierarchy
- trait \Drupal\search_api_solr\Utility\SolrCommitTrait
8 files declare their use of SolrCommitTrait
- FacetsTest.php in tests/
src/ Functional/ FacetsTest.php - IntegrationTest.php in tests/
src/ Functional/ IntegrationTest.php - IntegrationTest.php in modules/
search_api_solr_defaults/ tests/ src/ Functional/ IntegrationTest.php - SearchApiSolrBackend.php in src/
Plugin/ search_api/ backend/ SearchApiSolrBackend.php - SearchApiSolrTest.php in tests/
src/ Kernel/ SearchApiSolrTest.php
File
- src/
Utility/ SolrCommitTrait.php, line 12
Namespace
Drupal\search_api_solr\UtilityView source
trait SolrCommitTrait {
/**
* Explicitly sends a commit command to a Solr server.
*
* @param \Drupal\search_api\IndexInterface $index
* The Search API server entity.
*
* @throws \Drupal\Component\Plugin\Exception\PluginException
* @throws \Drupal\search_api\SearchApiException
*/
protected function ensureCommit(IndexInterface $index) {
if ($server = $index
->getServerInstance()) {
/** @var \Drupal\search_api_solr\SolrBackendInterface $backend */
$backend = $server
->getBackend();
/** @var \Drupal\search_api_solr\SolrConnectorInterface $connector */
$connector = $backend
->getSolrConnector();
$update = $connector
->getUpdateQuery();
$update
->addCommit(TRUE, TRUE, TRUE);
$connector
->update($update, $backend
->getCollectionEndpoint($index));
if (SOLR_INDEX_WAIT) {
sleep(SOLR_INDEX_WAIT);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SolrCommitTrait:: |
protected | function | Explicitly sends a commit command to a Solr server. |