function search_mark_for_reindex

search_mark_for_reindex($type = NULL, $sid = NULL, $langcode = NULL)

Changes the timestamp on indexed items to 'now' to force reindexing.

This function is meant for use by search page plugins, or for building a user interface that lets users mark all or parts of the search index for reindexing.

Parameters

string $type: (optional) The plugin ID or other machine-readable type of this item. If omitted, the entire search index is marked for reindexing, and $sid and $langcode are ignored.

int $sid: (optional) An ID number identifying this particular item (e.g., node ID). If omitted, everything matching $type is marked, and $langcode is ignored.

string $langcode: (optional) The language code to clear. If omitted, everything matching $type and $sid is marked.

File

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

Code

function search_mark_for_reindex($type = NULL, $sid = NULL, $langcode = NULL) {
  $query = db_update('search_dataset')
    ->fields(array('reindex' => REQUEST_TIME))
    // Only mark items that were not previously marked for reindex, so that
    // marked items maintain their priority by request time.
    ->condition('reindex', 0);

  if ($type) {
    $query->condition('type', $type);
    if ($sid) {
      $query->condition('sid', $sid);
      if ($langcode) {
        $query->condition('langcode', $langcode);
      }
    }
  }

  $query->execute();
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!search!search.module/function/search_mark_for_reindex/8.1.x