You are here

function drush_search_api_list in Search API 7

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

List all search indexes.

1 call to drush_search_api_list()
search_api_drush_get_index in ./search_api.drush.inc
Returns an index or all indexes as an array.

File

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

Code

function drush_search_api_list() {
  if (search_api_drush_static(__FUNCTION__)) {
    return;
  }

  // See search_api_list_indexes()
  $indexes = search_api_index_load_multiple(FALSE);
  if (empty($indexes)) {
    drush_print(dt('There are no indexes present.'));
    return;
  }
  $rows[] = array(
    dt('Id'),
    dt('Name'),
    dt('Index'),
    dt('Server'),
    dt('Type'),
    dt('Status'),
    dt('Limit'),
  );
  foreach ($indexes as $index) {
    $type = search_api_get_item_type_info($index->item_type);
    $type = isset($type['name']) ? $type['name'] : $index->item_type;
    try {
      $server = $index
        ->server();
      $server = $server ? $server->name : '(' . dt('none') . ')';
    } catch (SearchApiException $e) {
      watchdog_exception('search_api', $e);
      $server = '(' . dt('unknown: !server', array(
        'server' => $index->server,
      )) . ')';
    }
    $row = array(
      $index->id,
      $index->name,
      $index->machine_name,
      $server,
      $type,
      $index->enabled ? dt('enabled') : dt('disabled'),
      $index->options['cron_limit'],
    );
    $rows[] = $row;
  }
  drush_print_table($rows);
}