You are here

function search_index_clear in Drupal 8

Clears either a part of, or the entire search index.

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

Parameters

string|null $type: (optional) The plugin ID or other machine-readable type for the items to remove from the search index. If omitted, $sid and $langcode are ignored and the entire search index is cleared.

int|array|null $sid: (optional) The ID or array of IDs of the items to remove from the search index. If omitted, all items matching $type are cleared, and $langcode is ignored.

string|null $langcode: (optional) Language code of the item to remove from the search index. If omitted, all items matching $sid and $type are cleared.

Deprecated

in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\search\SearchIndex::clear() instead.

See also

https://www.drupal.org/node/3075696

1 call to search_index_clear()
SearchDeprecationTest::testClear in core/modules/search/tests/src/Kernel/SearchDeprecationTest.php
@expectedDeprecation search_index_clear() is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use \Drupal\search\SearchIndex::clear() instead. See https://www.drupal.org/node/3075696

File

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

Code

function search_index_clear($type = NULL, $sid = NULL, $langcode = NULL) {
  @trigger_error("search_index_clear() is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use \\Drupal\\search\\SearchIndex::clear() instead. See https://www.drupal.org/node/3075696", E_USER_DEPRECATED);
  \Drupal::service('search.index')
    ->clear($type, $sid, $langcode);
}