You are here

function hook_apachesolr_query_prepare in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 apachesolr.api.php \hook_apachesolr_query_prepare()
  2. 6.3 apachesolr.api.php \hook_apachesolr_query_prepare()

Prepare the query by adding parameters, sorts, etc.

This hook is invoked before the query is cached. The cached query is used after the search such as for building facet and sort blocks, so parameters added during this hook may be visible to end users.

This is otherwise the same as HOOK_apachesolr_query_alter(), but runs before it.

Parameters

DrupalSolrQueryInterface $query: An object implementing DrupalSolrQueryInterface. No need for &.

1 invocation of hook_apachesolr_query_prepare()
apachesolr_do_query in ./apachesolr.module
Execute a keyword search based on a query object.

File

./apachesolr.api.php, line 161
Exposed Hooks in 7.x:

Code

function hook_apachesolr_query_prepare(DrupalSolrQueryInterface $query) {

  // Add a sort on the node ID.
  $query
    ->setAvailableSort('entity_id', array(
    'title' => t('Node ID'),
    'default' => 'asc',
  ));
}