You are here

public function SearchApiElasticsearchElastica::deleteItems in Search API Elasticsearch 7

Overrides deleteItems().

Overrides SearchApiServiceInterface::deleteItems

File

modules/elastica/includes/SearchApiElasticsearchElastica.inc, line 297
Provides Elastica client for Search API Elasticsearch.

Class

SearchApiElasticsearchElastica
Search API Elasticsearch Elastica service class.

Code

public function deleteItems($ids = 'all', SearchApiIndex $index = NULL) {
  if (empty($index)) {
    foreach (search_api_index_load_multiple(FALSE, array(
      'server' => $this->server->machine_name,
    )) as $index) {
      $this
        ->deleteItems('all', $index);
    }
  }
  elseif ($ids === 'all') {
    $elastica_type = $this
      ->getElasticaType($index);
    if (!empty($elastica_type)) {
      $match_all = new Elastica\Query\MatchAll();
      $elastica_type
        ->deleteByQuery($match_all);
    }
  }
  else {
    $elastica_type = $this
      ->getElasticaType($index);
    if (!empty($elastica_type)) {
      $elastica_type
        ->deleteIds($ids);
    }
  }
}