You are here

trait SolrCommitTrait in Search API Solr 8.2

Same name and namespace in other branches
  1. 8.3 src/Utility/SolrCommitTrait.php \Drupal\search_api_solr\Utility\SolrCommitTrait
  2. 8 src/Utility/SolrCommitTrait.php \Drupal\search_api_solr\Utility\SolrCommitTrait
  3. 4.x src/Utility/SolrCommitTrait.php \Drupal\search_api_solr\Utility\SolrCommitTrait

Helper to ensure that solr index is up to date.

Hierarchy

8 files declare their use of SolrCommitTrait
FacetsTest.php in tests/src/Functional/FacetsTest.php
IntegrationTest.php in tests/src/Functional/IntegrationTest.php
MultilingualViewsTest.php in tests/src/Functional/MultilingualViewsTest.php
SearchApiSolrBackend.php in src/Plugin/search_api/backend/SearchApiSolrBackend.php
SearchApiSolrTest.php in tests/src/Kernel/SearchApiSolrTest.php

... See full list

File

src/Utility/SolrCommitTrait.php, line 12

Namespace

Drupal\search_api_solr\Utility
View source
trait SolrCommitTrait {

  /**
   * Explicitly sent a commit command to a Solr server.
   *
   * @param \Drupal\search_api\ServerInterface $server
   *
   * @throws \Drupal\search_api\SearchApiException
   */
  protected function ensureCommit(ServerInterface $server) {
    $backend = $server
      ->getBackend();

    /** @var \Drupal\search_api_solr\SolrConnectorInterface $connector */
    $connector = $backend
      ->getSolrConnector();
    $update = $connector
      ->getUpdateQuery();
    $update
      ->addCommit(TRUE, TRUE, TRUE);
    $connector
      ->update($update);
    if (SOLR_INDEX_WAIT) {
      sleep(SOLR_INDEX_WAIT);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SolrCommitTrait::ensureCommit protected function Explicitly sent a commit command to a Solr server.