You are here

function apachesolr_search_execute in Apache Solr Search 6.2

Same name and namespace in other branches
  1. 5.2 apachesolr_search.module \apachesolr_search_execute()
  2. 6 apachesolr_search.module \apachesolr_search_execute()

Execute a search results based on keyword, filter, and sort strings.

Parameters

$keys:

$filterstring:

$solrsort:

$base_path: For constructing filter and sort links. Leave empty unless the links need to point somewhere other than the base path of the current request.

integer $page: For pagination.

$caller:

Return value

Apache_Solr_Response $response

Throws

Exception

3 calls to apachesolr_search_execute()
apachesolr_drush_solr_search in drush/apachesolr.drush.inc
apachesolr_search_search in ./apachesolr_search.module
Implementation of hook_search().
apachesolr_search_taxonomy_term_page in ./apachesolr.taxonomy.inc
Overrides taxonomy/term/X links

File

./apachesolr_search.module, line 396
Provides a content search implementation for node content for use with the Apache Solr search application.

Code

function apachesolr_search_execute($keys, $filterstring, $solrsort, $base_path = '', $page = 0, $caller = 'apachesolr_search') {
  $params = array();

  // This is the object that knows about the query coming from the user.
  $query = apachesolr_drupal_query($keys, $filterstring, $solrsort, $base_path);
  if (empty($query)) {
    throw new Exception(t('Could not construct a Solr query in function apachesolr_search_search()'));
  }
  $params += apachesolr_search_basic_params($query);
  if ($keys) {
    $params += apachesolr_search_highlighting_params($query);
    $params += apachesolr_search_spellcheck_params($query);
  }
  else {

    // No highlighting, use the teaser as a snippet.
    $params['fl'] .= ',teaser';
  }
  if (module_exists('upload')) {
    $params['fl'] .= ',is_upload_count';
  }
  apachesolr_search_add_facet_params($params, $query);
  apachesolr_search_add_boost_params($params, $query, apachesolr_get_solr());
  list($final_query, $response) = apachesolr_do_query($caller, $query, $params, $page);
  apachesolr_has_searched(TRUE);

  // Add search terms and filters onto the breadcrumb.
  // We use the original $query to avoid exposing, for example, nodeaccess
  // filters in the breadcrumb.
  drupal_set_breadcrumb(array_merge(drupal_get_breadcrumb(), $query
    ->get_breadcrumb()));
  return apachesolr_search_process_response($response, $final_query, $params);
}