You are here

public function SearchApiElasticsearchBackend::deleteAllIndexItems in Elasticsearch Connector 8

Same name and namespace in other branches
  1. 8.7 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::deleteAllIndexItems()
  2. 8.2 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::deleteAllIndexItems()
  3. 8.5 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::deleteAllIndexItems()
  4. 8.6 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::deleteAllIndexItems()

Deletes all the items from the index.

Parameters

\Drupal\search_api\IndexInterface $index: The index for which items should be deleted.

string|null $datasource_id: (optional) If given, only delete items from the datasource with the given ID.

Throws

\Drupal\search_api\SearchApiException Thrown if an error occurred while trying to delete indexed items.

Overrides BackendSpecificInterface::deleteAllIndexItems

1 call to SearchApiElasticsearchBackend::deleteAllIndexItems()
SearchApiElasticsearchBackend::deleteItems in src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php
Overrides deleteItems().

File

src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php, line 562
Contains the SearchApiElasticsearchBackend object.

Class

SearchApiElasticsearchBackend
Plugin annotation @SearchApiBackend( id = "elasticsearch", label = @Translation("Elasticsearch"), description = @Translation("Index items using an Elasticsearch server.") )

Namespace

Drupal\elasticsearch_connector\Plugin\search_api\backend

Code

public function deleteAllIndexItems(IndexInterface $index) {
  $this
    ->removeIndex($index);
  $this
    ->addIndex($index);
}