You are here

public function SearchApiSolrBackend::removeIndex in Search API Solr 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::removeIndex()
  2. 8.2 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::removeIndex()
  3. 4.x src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::removeIndex()

Removes an index from this server.

This might mean that the index has been deleted, or reassigned to a different server. If you need to distinguish between these cases, inspect $index->getServerId().

If the index wasn't added to the server previously, the method call should be ignored.

Implementations of this method should also check whether $index->isReadOnly() and don't delete any indexed data if it is.

Parameters

\Drupal\search_api\IndexInterface|string $index: Either an object representing the index to remove, or its ID (if the index was completely deleted).

Throws

\Drupal\search_api\SearchApiException Thrown if an error occurred while removing the index.

Overrides BackendPluginBase::removeIndex

File

src/Plugin/search_api/backend/SearchApiSolrBackend.php, line 690

Class

SearchApiSolrBackend
Apache Solr backend for search api.

Namespace

Drupal\search_api_solr\Plugin\search_api\backend

Code

public function removeIndex($index) {

  // Only delete the index's data if the index isn't read-only. If the index
  // has already been deleted and we only get the ID, we just assume it was
  // read-only to be on the safe side.
  if (is_object($index) && !$index
    ->isReadOnly()) {
    $this
      ->deleteAllIndexItems($index);
  }
}