You are here

public function SearchApiElasticsearchBackend::deleteItems in Elasticsearch Connector 8.7

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

Deletes the specified items from the index.

Parameters

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

string[] $item_ids: The IDs of the deleted items.

Throws

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

Overrides BackendSpecificInterface::deleteItems

File

src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php, line 533

Class

SearchApiElasticsearchBackend
Elasticsearch Search API Backend definition.

Namespace

Drupal\elasticsearch_connector\Plugin\search_api\backend

Code

public function deleteItems(IndexInterface $index = NULL, array $ids) {
  if (!count($ids)) {
    return;
  }
  try {
    $this->client
      ->bulk($this->indexFactory
      ->bulkDelete($index, $ids));
  } catch (ElasticsearchException $e) {
    \Drupal::messenger()
      ->addError($e
      ->getMessage());
  }
}