You are here

function apachesolr_drush_solr_delete_index in Apache Solr Search 8

Same name and namespace in other branches
  1. 5.2 apachesolr.drush.inc \apachesolr_drush_solr_delete_index()
  2. 6.3 drush/apachesolr.drush.inc \apachesolr_drush_solr_delete_index()
  3. 6 drush/apachesolr.drush.inc \apachesolr_drush_solr_delete_index()
  4. 6.2 drush/apachesolr.drush.inc \apachesolr_drush_solr_delete_index()
  5. 7 drush/apachesolr.drush.inc \apachesolr_drush_solr_delete_index()

Selectively delete content from the apachesolr index.

Each argument is a filter on what to delete from the index. They are of the form entity (to delete all content of that entity) or entity:bundle (to delete all content of that bundle).

1 string reference to 'apachesolr_drush_solr_delete_index'
apachesolr_drush_command in drush/apachesolr.drush.inc
Implements hook_drush_command().

File

drush/apachesolr.drush.inc, line 215
drush integration for apachesolr.

Code

function apachesolr_drush_solr_delete_index() {
  module_load_include('inc', 'apachesolr', 'apachesolr.index');
  $args = func_get_args();
  $env_id = drush_get_option('environment-id');
  if (empty($env_id)) {
    $env_id = apachesolr_default_environment();
  }
  if (count($args) > 0) {
    foreach ($args as $type) {
      $parts = explode(':', $type);
      if (count($parts) === 1) {
        apachesolr_index_delete_index($env_id, $type);
      }
      elseif (count($parts) == 2) {
        apachesolr_index_delete_index($env_id, $parts[0], $parts[1]);
      }
      else {
        drush_set_error('The syntax for each type is either entity or entity:bundle');
      }
    }
  }
  else {
    apachesolr_index_delete_index($env_id);
  }
  drush_print(t('Deleted the Solr index'));
}