You are here

function acquia_search_apachesolr_modify_query in Acquia Search 6

Implementation of hook_apachesolr_modify_query().

Possibly alters the query type ('defType') param to edismax.

File

./acquia_search.module, line 204
Integration between Acquia Drupal and Acquia's hosted solr search service.

Code

function acquia_search_apachesolr_modify_query($query, &$params, $caller) {

  // @todo - does it make sense to check $caller too?
  if (isset($params['qt']) || isset($params['defType'])) {

    // This is a 'mlt' query or something else custom.
    return;
  }

  // Set the qt to edismax if we have keywords, and we always use it, or are
  // using a wildcard (* or ?).
  $keys = $query
    ->get_query_basic();
  if ($keys && (($wildcard = preg_match('/\\S+[*?]/', $keys)) || variable_get('acquia_search_edismax_default', 0))) {
    $params['defType'] = 'edismax';
    if ($wildcard) {
      $keys = preg_replace_callback('/(\\S+[*?]\\S*)/', '_acquia_search_lower', $keys);
      $query
        ->set_keys($keys);
    }
  }
}