function apachesolr_delete_index in Apache Solr Search 6
Same name and namespace in other branches
- 5.2 apachesolr.admin.inc \apachesolr_delete_index()
- 6.2 apachesolr.admin.inc \apachesolr_delete_index()
Utility function to delete the index and reset all index counters.
Parameters
$type: a single content type to be deleted from the index.
Throws
Exception
2 calls to apachesolr_delete_index()
- apachesolr_delete_index_confirm_submit in ./
apachesolr.admin.inc - Submit function for the "Delete the index" confirmation form.
- apachesolr_drush_solr_delete_index in drush/
apachesolr.drush.inc - Example drush command callback.
File
- ./
apachesolr.admin.inc, line 455 - Administrative pages for the Apache Solr framework.
Code
function apachesolr_delete_index($type = NULL) {
// Instantiate a new Solr object.
$solr = apachesolr_get_solr();
if ($type) {
$query = 'type:' . $type;
}
else {
$query = '*:*';
}
// Allow other modules to modify the delete query.
// For example, use the site hash so that you only delete this site's
// content: $query = 'hash:' . apachesolr_site_hash()
drupal_alter('apachesolr_delete_index', $query);
$solr
->deleteByQuery($query);
$solr
->commit();
// Rebuild our node-tracking table.
apachesolr_rebuild_index_table();
apachesolr_index_updated(time());
}