public function SearchApiSolrBackend::deleteItems in Search API Solr 8
Same name and namespace in other branches
- 8.3 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::deleteItems()
- 8.2 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::deleteItems()
- 4.x src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::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/ SearchApiSolrBackend.php, line 839
Class
- SearchApiSolrBackend
- Apache Solr backend for search api.
Namespace
Drupal\search_api_solr\Plugin\search_api\backendCode
public function deleteItems(IndexInterface $index, array $ids) {
try {
$index_id = $this
->getIndexId($index
->id());
$solr_ids = array();
foreach ($ids as $id) {
$solr_ids[] = $this
->createId($index_id, $id);
}
$connector = $this
->getSolrConnector();
$update_query = $connector
->getUpdateQuery();
$update_query
->addDeleteByIds($solr_ids);
$connector
->update($update_query);
} catch (ExceptionInterface $e) {
throw new SearchApiSolrException($e
->getMessage(), $e
->getCode(), $e);
}
}