private function SearchApiElasticsearchConnector::deleteItemsIds in Elasticsearch Connector 7.5
Same name and namespace in other branches
- 7 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::deleteItemsIds()
- 7.2 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::deleteItemsIds()
Helper function for bulk delete operation.
Parameters
array $ids:
SearchApiIndex $index:
Return value
void
1 call to SearchApiElasticsearchConnector::deleteItemsIds()
- SearchApiElasticsearchConnector::deleteItems in modules/
elasticsearch_connector_search_api/ service.inc - Overrides deleteItems().
File
- modules/
elasticsearch_connector_search_api/ service.inc, line 576 - Provides a Elasticsearch-based service class for the Search API using Elasticsearch Connector module.
Class
- SearchApiElasticsearchConnector
- Search service class.
Code
private function deleteItemsIds($ids, SearchApiIndex $index) {
$params = $this
->getIndexParam($index, TRUE);
foreach ($ids as $id) {
$params['body'][] = array(
'delete' => array(
'_type' => $params['type'],
'_id' => $this
->getSafeId($id),
),
);
}
try {
$response = $this->elasticsearchClient
->bulk($params);
// If error throw the error we have.
if (!empty($response['errors'])) {
foreach ($response['items'] as $item) {
if (!empty($item['delete']['status']) && $item['delete']['status'] == '400') {
throw new SearchApiElasticsearchConnectorException($item['index']['error']);
}
}
}
} catch (Exception $e) {
drupal_set_message($e
->getMessage(), 'error');
}
}