You are here

function apachesolr_delete_index in Apache Solr Search 6.2

Same name and namespace in other branches
  1. 5.2 apachesolr.admin.inc \apachesolr_delete_index()
  2. 6 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 489
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_set_last_updated(time());
}