function hook_apachesolr_query_alter in Apache Solr Search 8
Same name and namespace in other branches
- 6.3 apachesolr.api.php \hook_apachesolr_query_alter()
- 7 apachesolr.api.php \hook_apachesolr_query_alter()
Alter the query after it's prepared and cached.
Any module performing a search should call drupal_alter('apachesolr_query', $query). That function then invokes this hook. It allows modules to modify the query object and its parameters.
A module implementing HOOK_apachesolr_query_alter() may set $query->abort_search to TRUE to flag the query to be aborted.
Parameters
DrupalSolrQueryInterface $query: An object implementing DrupalSolrQueryInterface. No need for &.
1 function implements hook_apachesolr_query_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- apachesolr_access_apachesolr_query_alter in apachesolr_access/
apachesolr_access.module - Implements hook_apachesolr_query_alter().
2 invocations of hook_apachesolr_query_alter()
- apachesolr_do_query in ./
apachesolr.module - Execute a keyword search based on a query object.
- apachesolr_search_mlt_suggestions in ./
apachesolr_search.module - Performs a moreLikeThis query using the settings and retrieves documents.
File
- ./
apachesolr.api.php, line 191 - Exposed Hooks in 7.x:
Code
function hook_apachesolr_query_alter(DrupalSolrQueryInterface $query) {
// I only want to see articles by the admin.
//
// NOTE: this "is_uid" filter does NOT refer to the English word "is"
// It is a combination of flags representing Integer-Single, which is
// abbreviated with the letters i and s.
//
// @see the <dynamicField> definitions in schema.xml or schema-solr3.xml
$query
->addFilter("is_uid", 1);
// Only search titles.
$query
->replaceParam('qf', 'label');
}