public function SearchApiSolrBackend::deleteAllIndexItems in Search API Solr 8.3
Same name and namespace in other branches
- 8 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::deleteAllIndexItems()
- 8.2 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::deleteAllIndexItems()
- 4.x src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::deleteAllIndexItems()
Throws
\Drupal\Component\Plugin\Exception\PluginException
\Drupal\search_api\SearchApiException
Overrides BackendSpecificInterface::deleteAllIndexItems
File
- src/
Plugin/ search_api/ backend/ SearchApiSolrBackend.php, line 1172
Class
- SearchApiSolrBackend
- Apache Solr backend for search api.
Namespace
Drupal\search_api_solr\Plugin\search_api\backendCode
public function deleteAllIndexItems(IndexInterface $index, $datasource_id = NULL) {
// Since the index ID we use for indexing can contain arbitrary
// prefixes, we have to escape it for use in the query.
$connector = $this
->getSolrConnector();
$index_id = $this->queryHelper
->escapeTerm($this
->getTargetedIndexId($index));
$site_hash = $this->queryHelper
->escapeTerm($this
->getTargetedSiteHash($index));
$query = '+index_id:' . $index_id;
$query .= ' +hash:' . $site_hash;
if ($datasource_id) {
$query .= ' +' . $this
->getSolrFieldNames($index)['search_api_datasource'] . ':' . $this->queryHelper
->escapeTerm($datasource_id);
}
$update_query = $connector
->getUpdateQuery();
$update_query
->addDeleteQuery($query);
$connector
->update($update_query, $this
->getCollectionEndpoint($index));
// Delete corresponding checkpoints.
if ($connector
->isCloud()) {
/** @var \Drupal\search_api_solr\SolrCloudConnectorInterface $connector */
$connector
->deleteCheckpoints($index_id, $site_hash);
}
\Drupal::state()
->set('search_api_solr.' . $index
->id() . '.last_update', \Drupal::time()
->getCurrentTime());
}