You are here

public function ApachesolrSearchService::search in Fast Autocomplete 7

Implements SearchServiceInterface::search().

Parameters

string $key: The key to use in the search.

string $language: The language to use in the search.

Return value

array The results array containing the resulting nids.

Overrides AbstractSearchService::search

File

src/SearchService/ApachesolrSearchService.php, line 21

Class

ApachesolrSearchService
Fast Autocomplete backend service class providing Apachesolr search.

Namespace

Drupal\fac\SearchService

Code

public function search($key, $language) {
  $result = array();
  $settings = variable_get('fac_backend_service_settings', array());
  $rows = isset($settings['number_of_results']) ? $settings['number_of_results'] : 5;
  $search_results = apachesolr_search_run('fac', array(
    'q' => $key,
    'rows' => $rows,
  ), 'score');
  foreach ($search_results as $sr) {
    $result['items'][] = array(
      'entity_type' => $sr['entity_type'],
      'etid' => $sr['fields']['entity_id'],
    );
  }
  return $result;
}