hook_apachesolr_query_prepare

  1. apachesolr
    1. 7
Versions
7 hook_apachesolr_query_prepare($query)

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

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

Code

./apachesolr.api.php, line 19

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