You are here

public function BackendPluginBase::removeIndex in Search API 8

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 BackendSpecificInterface::removeIndex

2 methods override BackendPluginBase::removeIndex()
Database::removeIndex in modules/search_api_db/src/Plugin/search_api/backend/Database.php
Removes an index from this server.
TestBackend::removeIndex in tests/search_api_test/src/Plugin/search_api/backend/TestBackend.php
Removes an index from this server.

File

src/Backend/BackendPluginBase.php, line 255

Class

BackendPluginBase
Defines a base class for backend plugins.

Namespace

Drupal\search_api\Backend

Code

public function removeIndex($index) {

  // Only delete the index's data if the index isn't read-only. (If only the
  // ID is given, we assume the index was read-only, to be on the safe side.)
  if ($index instanceof IndexInterface && !$index
    ->isReadOnly()) {
    $this
      ->deleteAllIndexItems($index);
  }
}