public function SearchIndex::markForReindex in Drupal 10
Same name and namespace in other branches
- 8 core/modules/search/src/SearchIndex.php \Drupal\search\SearchIndex::markForReindex()
- 9 core/modules/search/src/SearchIndex.php \Drupal\search\SearchIndex::markForReindex()
File
- core/
modules/ search/ src/ SearchIndex.php, line 264
Class
- SearchIndex
- Provides search index management functions.
Namespace
Drupal\searchCode
public function markForReindex($type = NULL, $sid = NULL, $langcode = NULL) {
try {
$query = $this->connection
->update('search_dataset')
->fields([
'reindex' => 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();
} catch (\Exception $e) {
throw new SearchIndexException("Failed to mark index for re-indexing for type '{$type}', sid '{$sid}' and langcode '{$langcode}'", 0, $e);
}
}