You are here

function facetapi_apachesolr_apachesolr_prepare_query in Facet API 6

Implementation of hook_apachesolr_prepare_query().

Invokes type hooks, adds filters.

File

contrib/facetapi_apachesolr/facetapi_apachesolr.module, line 71
The Apache Solr Search Integration module's implementation of the the Facet API.

Code

function facetapi_apachesolr_apachesolr_prepare_query($query, &$params, $caller) {
  facetapi_query_type_hooks_invoke('apachesolr_search', $params, $query);

  // Gets enabled facets, adds filter queries to $params.
  $adapter = facetapi_adapter_load('apachesolr_search');
  foreach (facetapi_enabled_facets_get('apachesolr_search') as $facet) {
    $queries = array();
    foreach ($adapter
      ->getActiveItems($facet) as $value => $item) {
      $queries[] = $facet['field alias'] . ':' . $value;
    }
    if (!empty($queries)) {
      $params['fq'][$facet['field alias']] = $queries;
    }
  }
}