function acquia_search_apachesolr_query_alter in Acquia Connector 7
Same name and namespace in other branches
- 7.3 acquia_search/acquia_search.module \acquia_search_apachesolr_query_alter()
- 7.2 acquia_search/acquia_search.module \acquia_search_apachesolr_query_alter()
Implementation of hook_apachesolr_modify_query().
Possibly alters the query type ('defType') param to edismax.
File
- acquia_search/
acquia_search.module, line 346 - Integration between Acquia Drupal and Acquia's hosted solr search service.
Code
function acquia_search_apachesolr_query_alter($query) {
// @todo - does it make sense to check $caller too?
if (!acquia_search_environment_connected($query
->solr('getId')) || $query
->getParam('qt') || $query
->getParam('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
->getParam('q');
if ($keys && (($wildcard = preg_match('/\\S+[*?]/', $keys)) || variable_get('acquia_search_edismax_default', 0))) {
$query
->addParam('defType', 'edismax');
if ($wildcard) {
$keys = preg_replace_callback('/(\\S+[*?]\\S*)/', '_acquia_search_lower', $keys);
$query
->replaceParam('q', $keys);
}
}
}