public function SearchApiCommands::index in Search API 8
Indexes items for one or all enabled search indexes.
@command search-api:index
@option limit The maximum number of items to index. Set to 0 to index all items. Defaults to 0 (index all). @option batch-size The maximum number of items to index per batch run. Set to 0 to index all items at once. Defaults to the "Cron batch size" setting of the index.
@usage drush search-api:index Index all items for all enabled indexes. @usage drush sapi-i Alias to index all items for all enabled indexes. @usage drush sapi-i node_index Index all items for the index with the ID node_index. @usage drush sapi-i --limit=100 node_index Index a maximum number of 100 items for the index with the ID node_index. @usage drush sapi-i --limit=100 --batch-size=10 node_index Index a maximum number of 100 items (10 items per batch run) for the index with the ID node_index.
@aliases sapi-i,search-api-index
Parameters
string $indexId: (optional) A search index ID, or NULL to index items for all enabled indexes.
array $options: (optional) An array of options.
Throws
\Exception If a batch process could not be created.
File
- src/
Commands/ SearchApiCommands.php, line 241
Class
- SearchApiCommands
- Defines Drush commands for the Search API.
Namespace
Drupal\search_api\CommandsCode
public function index($indexId = NULL, array $options = [
'limit' => NULL,
'batch-size' => NULL,
]) {
$limit = $options['limit'];
$batch_size = $options['batch-size'];
$process_batch = $this->commandHelper
->indexItemsToIndexCommand([
$indexId,
], $limit, $batch_size);
if ($process_batch === TRUE) {
drush_backend_batch_process();
}
}