function drush_search_reindex

8.0.x search.drush.inc drush_search_reindex()
6.x search.drush.inc drush_search_reindex()
7.x search.drush.inc drush_search_reindex()
5.x search.drush.inc drush_search_reindex()
master search.drush.inc drush_search_reindex()

File

commands/core/search.drush.inc, line 156

Code

function drush_search_reindex() {
  drush_print(dt("The search index must be fully rebuilt before any new items can be indexed."));
  if (drush_get_option('immediate')) {
    drush_print(dt("Rebuilding the index may take a long time."));
  }
  if (!drush_confirm(dt('Do you really want to continue?'))) {
    return drush_user_abort();
  }

  if (drush_drupal_major_version() == 8) {
    // D8 CR: https://www.drupal.org/node/2326575
    $search_page_repository = \Drupal::service('search.search_page_repository');
    foreach ($search_page_repository->getIndexableSearchPages() as $entity) {
      $entity->getPlugin()->markForReindex();
    }
  }
  elseif (drush_drupal_major_version() == 7) {
    drush_op('search_reindex');
  }
  else {
    drush_op('search_wipe');
  }

  if (drush_get_option('immediate')) {
    drush_op('_drush_search_index');
    drush_log(dt('The search index has been rebuilt.'), LogLevel::OK);
  }
  else {
    drush_log(dt('The search index will be rebuilt.'), LogLevel::OK);
  }
}