public function SearchApiAlgoliaBackend::deleteAllIndexItems in Search API Algolia 8
Same name and namespace in other branches
- 3.0.x src/Plugin/search_api/backend/SearchApiAlgoliaBackend.php \Drupal\search_api_algolia\Plugin\search_api\backend\SearchApiAlgoliaBackend::deleteAllIndexItems()
- 2.0.x src/Plugin/search_api/backend/SearchApiAlgoliaBackend.php \Drupal\search_api_algolia\Plugin\search_api\backend\SearchApiAlgoliaBackend::deleteAllIndexItems()
Deletes all the items from the index.
Parameters
\Drupal\search_api\IndexInterface $index: The index for which items should be deleted.
string|null $datasource_id: (optional) If given, only delete items from the datasource with the given ID.
Throws
\Drupal\search_api\SearchApiException Thrown if an error occurred while trying to delete indexed items.
Overrides BackendSpecificInterface::deleteAllIndexItems
1 call to SearchApiAlgoliaBackend::deleteAllIndexItems()
- SearchApiAlgoliaBackend::removeIndex in src/
Plugin/ search_api/ backend/ SearchApiAlgoliaBackend.php - Removes an index from this server.
File
- src/
Plugin/ search_api/ backend/ SearchApiAlgoliaBackend.php, line 375
Class
- SearchApiAlgoliaBackend
- Class SearchApiAlgoliaBackend.
Namespace
Drupal\search_api_algolia\Plugin\search_api\backendCode
public function deleteAllIndexItems(IndexInterface $index = NULL, $datasource_id = NULL) {
if ($index) {
if ($this->languageManager
->isMultilingual()) {
foreach ($this->languageManager
->getLanguages() as $language) {
// Connect to the Algolia service.
$this
->connect($index, '', $language
->getId());
// Clearing the full index.
$this
->getAlgoliaIndex()
->clearIndex();
}
}
else {
// Connect to the Algolia service.
$this
->connect($index);
// Clearing the full index.
$this
->getAlgoliaIndex()
->clearIndex();
}
}
}