You are here

function search_api_drush_command in Search API 8

Same name and namespace in other branches
  1. 7 search_api.drush.inc \search_api_drush_command()

Implements hook_drush_command().

File

./search_api.drush.inc, line 14
Drush commands for Search API.

Code

function search_api_drush_command() {
  $items = [];
  $index['index_id'] = dt('The machine name of an index');
  $server['server_id'] = dt('The machine name of a server');
  $items['search-api-list'] = [
    'description' => 'List all search indexes.',
    'examples' => [
      'drush search-api-list' => dt('List all search indexes.'),
      'drush sapi-l' => dt('Alias to list all search indexes.'),
    ],
    'aliases' => [
      'sapi-l',
    ],
  ];
  $items['search-api-enable'] = [
    'description' => 'Enable one or more disabled search indexes.',
    'examples' => [
      'drush search-api-enable node_index' => dt('Enable the search index with the ID @name.', [
        '@name' => 'node_index',
      ]),
      'drush sapi-en node_index' => dt('Alias to enable the search index with the ID @name.', [
        '@name' => 'node_index',
      ]),
    ],
    'arguments' => $index,
    'aliases' => [
      'sapi-en',
    ],
  ];
  $items['search-api-enable-all'] = [
    'description' => 'Enable all disabled search indexes.',
    'examples' => [
      'drush search-api-enable-all' => dt('Enable all disabled indexes.'),
      'drush sapi-ena' => dt('Alias to enable all disabled indexes.'),
    ],
    'arguments' => [],
    'aliases' => [
      'sapi-ena',
    ],
  ];
  $items['search-api-disable'] = [
    'description' => 'Disable one or more enabled search indexes.',
    'examples' => [
      'drush search-api-disable node_index' => dt('Disable the search index with the ID @name.', [
        '@name' => 'node_index',
      ]),
      'drush sapi-dis node_index' => dt('Alias to disable the search index with the ID @name.', [
        '@name' => 'node_index',
      ]),
    ],
    'arguments' => $index,
    'aliases' => [
      'sapi-dis',
    ],
  ];
  $items['search-api-disable-all'] = [
    'description' => 'Disable all enabled search indexes.',
    'examples' => [
      'drush search-api-disable-all' => dt('Disable all enabled indexes.'),
      'drush sapi-disa' => dt('Alias to disable all enabled indexes.'),
    ],
    'arguments' => [],
    'aliases' => [
      'sapi-disa',
    ],
  ];
  $items['search-api-status'] = [
    'description' => 'Show the status of one or all search indexes.',
    'examples' => [
      'drush search-api-status' => dt('Show the status of all search indexes.'),
      'drush sapi-s' => dt('Alias to show the status of all search indexes.'),
      'drush sapi-s node_index' => dt('Show the status of the search index with the ID @name.', [
        '@name' => 'node_index',
      ]),
    ],
    'arguments' => $index,
    'aliases' => [
      'sapi-s',
    ],
  ];
  $items['search-api-index'] = [
    'description' => 'Index items for one or all enabled search indexes.',
    'examples' => [
      'drush search-api-index' => dt('Index all items for all enabled indexes.'),
      'drush sapi-i' => dt('Alias to index all items for all enabled indexes.'),
      'drush sapi-i node_index' => dt('Index all items for the index with the ID @name.', [
        '@name' => 'node_index',
      ]),
      'drush sapi-i --limit=100 node_index' => dt('Index a maximum number of @limit items for the index with the ID @name.', [
        '@limit' => 100,
        '@name' => 'node_index',
      ]),
      'drush sapi-i --limit=100 --batch-size=10 node_index' => dt('Index a maximum number of @limit items (@batch_size items per batch run) for the index with the ID @name.', [
        '@limit' => 100,
        '@batch_size' => 10,
        '@name' => 'node_index',
      ]),
    ],
    'options' => [
      'limit' => dt('The number of items to index. Set to 0 to index all items. Defaults to 0 (index all).'),
      'batch-size' => dt('The number of items to index per batch run. Set to 0 to index all items at once. Defaults to the "!batch_size_label" setting of the index.', [
        '!batch_size_label' => dt('Cron batch size'),
      ]),
    ],
    'arguments' => $index,
    'aliases' => [
      'sapi-i',
    ],
  ];
  $items['search-api-reset-tracker'] = [
    'description' => 'Force reindexing of one or all search indexes, without deleting existing index data.',
    'examples' => [
      'drush search-api-reindex' => dt('Schedule all search indexes for reindexing.'),
      'drush sapi-r' => dt('Alias to schedule all search indexes for reindexing .'),
      'drush sapi-r node_index' => dt('Schedule the search index with the ID @name for reindexing.', [
        '@name' => 'node_index',
      ]),
    ],
    'options' => [
      'entity-types' => [
        'description' => dt('List of entity type ids to reset tracker for.'),
        'example_value' => 'user,node',
      ],
    ],
    'arguments' => $index,
    'aliases' => [
      'search-api-mark-all',
      'search-api-reindex',
      'sapi-r',
    ],
  ];
  $items['search-api-clear'] = [
    'description' => 'Clear one or all search indexes and mark them for reindexing.',
    'examples' => [
      'drush search-api-clear' => dt('Clear all search indexes.'),
      'drush sapi-c' => dt('Alias to clear all search indexes.'),
      'drush sapi-c node_index' => dt('Clear the search index with the ID @name.', [
        '@name' => 'node_index',
      ]),
    ],
    'arguments' => $index,
    'aliases' => [
      'sapi-c',
    ],
  ];
  $items['search-api-search'] = [
    'description' => 'Search for a keyword or phrase in a given index.',
    'examples' => [
      'drush search-api-search node_index title' => dt('Search for "title" inside the "node_index" index.'),
      'drush sapi-search node_index title' => dt('Alias to search for "title" inside the "node_index" index.'),
    ],
    'arguments' => $index + [
      'keyword' => dt('The keyword to look for.'),
    ],
    'aliases' => [
      'sapi-search',
    ],
  ];
  $items['search-api-server-list'] = [
    'description' => 'List all search servers.',
    'examples' => [
      'drush search-api-server-list' => dt('List all search servers.'),
      'drush sapi-sl' => dt('Alias to list all search servers.'),
    ],
    'aliases' => [
      'sapi-sl',
    ],
  ];
  $items['search-api-server-enable'] = [
    'description' => 'Enable a search server.',
    'examples' => [
      'drush search-api-server-e my_solr_server' => dt('Enable the @server search server.', [
        '@server' => 'my_solr_server',
      ]),
      'drush sapi-se my_solr_server' => dt('Alias to enable the @server search server.', [
        '@server' => 'my_solr_server',
      ]),
    ],
    'arguments' => $server,
    'aliases' => [
      'sapi-se',
    ],
  ];
  $items['search-api-server-disable'] = [
    'description' => 'Disable a search server.',
    'examples' => [
      'drush search-api-server-disable' => dt('Disable the @server search server.', [
        '@server' => 'my_solr_server',
      ]),
      'drush sapi-sd' => dt('Alias to disable the @server search server.', [
        '@server' => 'my_solr_server',
      ]),
    ],
    'arguments' => $server,
    'aliases' => [
      'sapi-sd',
    ],
  ];
  $items['search-api-server-clear'] = [
    'description' => 'Clear all search indexes on the search server and mark them for reindexing.',
    'examples' => [
      'drush search-api-server-clear' => dt('Clear all search indexes on the search server @server.', [
        '@server' => 'my_solr_server',
      ]),
      'drush sapi-sc' => dt('Alias to clear all search indexes on the search server @server.', [
        '@server' => 'my_solr_server',
      ]),
    ],
    'arguments' => $server,
    'aliases' => [
      'sapi-sc',
    ],
  ];
  $items['search-api-set-index-server'] = [
    'description' => 'Set the search server used by a given index.',
    'examples' => [
      'drush search-api-set-index-server default_node_index my_solr_server' => dt('Set the @index index to used the @server server.', [
        '@index' => 'default_node_index',
        '@server' => 'my_solr_server',
      ]),
      'drush sapi-sis default_node_index my_solr_server' => dt('Alias to set the @index index to used the @server server.', [
        '@index' => 'default_node_index',
        '@server' => 'my_solr_server',
      ]),
    ],
    'arguments' => $index + $server,
    'aliases' => [
      'sapi-sis',
    ],
  ];
  return $items;
}