You are here

function search_api_facetapi_search_api_query_alter in Search API 7

Implements hook_search_api_query_alter().

Adds Facet API support to the query.

File

contrib/search_api_facetapi/search_api_facetapi.module, line 207
Integrates the Search API with the Facet API.

Code

function search_api_facetapi_search_api_query_alter($query) {
  $index = $query
    ->getIndex();
  if ($index
    ->server()
    ->supportsFeature('search_api_facets')) {

    // This is the main point of communication between the facet system and the
    // search back-end - it makes the query respond to active facets.
    search_api_facetapi_current_search_path($query);
    $searcher = 'search_api@' . $index->machine_name;
    $adapter = facetapi_adapter_load($searcher);
    if ($adapter) {
      $adapter
        ->addActiveFilters($query);
    }
  }
}