You are here

function apachesolr_panels_search_execute in Apache Solr Panels 6.3

Same name and namespace in other branches
  1. 6 apachesolr_panels.module \apachesolr_panels_search_execute()
  2. 7 apachesolr_panels.module \apachesolr_panels_search_execute()

Execute a Solr search.

Using hook_search() would make this module a first-class search module alongside Apache Solr Search, which we don't want. Instead, we execute the search directly and imitate what the core Search module does.

See also

search_data()

1 call to apachesolr_panels_search_execute()
apachesolr_panels_apachesolr_result_content_type_render in plugins/content_types/apachesolr_result.inc
Render the search results.

File

./apachesolr_panels.module, line 89
Integrates Apache Solr Search with Panels.

Code

function apachesolr_panels_search_execute($search) {

  // Store information about the search for use in other panes.
  apachesolr_panels_static_search_cache($search);
  $results = NULL;
  try {
    $solr = apachesolr_get_solr($search['env_id']);
    $results = apachesolr_search_run('apachesolr' . uniqid(), array_filter(array(
      'q' => $search['keys'],
      'fq' => $search['filters'],
      'rows' => $search['rows'],
    )), $search['sort'], $search['path'], $search['page'], $solr);
  } catch (Exception $e) {
    watchdog('Apache Solr', nl2br(check_plain($e
      ->getMessage())), NULL, WATCHDOG_ERROR);
    apachesolr_failure(t('Solr search'), $search['keys']);
  }

  // Imitate search_data() to present the results as Apache Solr Search would.
  if (is_array($results) && count($results)) {
    return theme('search_results', $results, 'apachesolr_search', array(
      'env_id' => $search['env_id'],
    ));
  }
}