You are here

function hook_search_api_solr_autocomplete_suggestions_alter in Search API Solr 7

Alter autocomplete suggestions returned from Solr servers.

Parameters

array $suggestions: An array of suggestions to be altered, in the structure documented in SearchApiAutocompleteSuggesterInterface::getAutocompleteSuggestions().

array $alter_data: An associative array of data about the search, with the following keys: "search", "query", "incomplete_key", "user_input", which correspond to the arguments to SearchApiAutocompleteInterface::getAutocompleteSuggestions(); and "responses", an array containing the Solr response objects used for constructing the suggestions.

1 invocation of hook_search_api_solr_autocomplete_suggestions_alter()
SearchApiSolrService::getAutocompleteSuggestions in includes/service.inc

File

./search_api_solr.api.php, line 177
Hooks provided by the Search API Solr search module.

Code

function hook_search_api_solr_autocomplete_suggestions_alter(array &$suggestions, array &$alter_data) {

  // Always also suggest the original user input.
  array_unshift($suggestions, trim($alter_data['user_input']));
}