You are here

function search_api_server_clear in Search API 7

Clears a search server.

Will delete all items stored on the server and mark all associated indexes for re-indexing.

Parameters

int|string $id: The ID or machine name of the server to clear.

Return value

bool TRUE on success, FALSE on failure.

File

./search_api.module, line 2779
Provides a flexible framework for implementing search services.

Code

function search_api_server_clear($id) {
  $server = search_api_server_load($id);
  $success = TRUE;
  foreach (search_api_index_load_multiple(FALSE, array(
    'server' => $server->machine_name,
  )) as $index) {
    $success &= $index
      ->reindex();
  }
  if ($success) {
    $server
      ->deleteItems();
  }
  return $success;
}