You are here

function hook_search_api_results_alter in Search API 7

Same name and namespace in other branches
  1. 8 search_api.api.php \hook_search_api_results_alter()

Alter the search results before they are returned.

Parameters

array $results: The results returned by the server, which may be altered. The data structure is the same as returned by SearchApiQueryInterface::execute().

SearchApiQueryInterface $query: The search query that was executed.

1 invocation of hook_search_api_results_alter()
SearchApiQuery::postExecute in includes/query.inc
Postprocesses the search results before they are returned.

File

./search_api.api.php, line 357
Hooks provided by the Search API module.

Code

function hook_search_api_results_alter(array &$results, SearchApiQueryInterface $query) {
  if ($query
    ->getOption('search id') == 'search_api_views:my_search_view:page') {

    // Log the number of results.
    $vars = array(
      '@keys' => $query
        ->getOriginalKeys(),
      '@num' => $results['result count'],
    );
    watchdog('my_module', 'Search view with query "@keys" had @num results.', $vars, WATCHDOG_DEBUG);
  }
}