function search_reindex

Clears a part of or the entire search index.

Parameters

$sid: (optional) The ID of the item to remove from the search index. If specified, $module must also be given. Omit both $sid and $module to clear the entire search index.

$module: (optional) The machine-readable name of the module for the item to remove from the search index.

$reindex: (optional) Boolean to specify whether reindexing happens.

$langcode: (optional) Language code for the operation. If not provided, all index records for the $sid will be deleted.

4 calls to search_reindex()
NodeStorageController::preDelete in drupal/core/modules/node/lib/Drupal/node/NodeStorageController.php
Overrides Drupal\Core\Entity\DatabaseStorageController::preDelete().
search_admin_settings_submit in drupal/core/modules/search/search.admin.inc
Form submission handler for search_admin_settings().
search_index in drupal/core/modules/search/search.module
Update the full-text search index for a particular item.
search_reindex_confirm_submit in drupal/core/modules/search/search.admin.inc
Handler for wipe confirmation

File

drupal/core/modules/search/search.module, line 324
Enables site-wide keyword searching.

Code

function search_reindex($sid = NULL, $module = NULL, $reindex = FALSE, $langcode = NULL) {
  if ($module == NULL && $sid == NULL) {
    module_invoke_all('search_reset');
  }
  else {
    $query = db_delete('search_dataset')
      ->condition('sid', $sid)
      ->condition('type', $module);
    if (!empty($langcode)) {
      $query
        ->condition('langcode', $langcode);
    }
    $query
      ->execute();
    $query = db_delete('search_index')
      ->condition('sid', $sid)
      ->condition('type', $module);
    if (!empty($langcode)) {
      $query
        ->condition('langcode', $langcode);
    }
    $query
      ->execute();

    // Don't remove links if re-indexing.
    if (!$reindex) {
      db_delete('search_node_links')
        ->condition('sid', $sid)
        ->condition('type', $module)
        ->execute();
    }
  }
}