You are here

function drush_search_api_clear in Search API 7

Same name and namespace in other branches
  1. 8 search_api.drush.inc \drush_search_api_clear()

Clear an index.

File

./search_api.drush.inc, line 506
Drush commands for SearchAPI.

Code

function drush_search_api_clear($index_id = NULL) {
  if (search_api_drush_static(__FUNCTION__)) {
    return;
  }
  $indexes = search_api_drush_get_index($index_id);
  if (empty($indexes)) {
    return;
  }

  // See search_api_index_reindex()
  foreach ($indexes as $index) {
    $index
      ->clear();
    drush_log(dt('!index was successfully cleared.', array(
      '!index' => $index->machine_name,
    )), 'ok');
  }
}