You are here

public function SearchApiGroupingGrouping::preprocessSearchQuery in Search API Grouping 7

Set the options so the server adapter can use the to implement grouping.

Overrides SearchApiAbstractProcessor::preprocessSearchQuery

File

includes/processor_grouping.inc, line 128
Processor for grouping support.

Class

SearchApiGroupingGrouping
Processor for grouping up items on behalf of user defined fields.

Code

public function preprocessSearchQuery(SearchApiQuery $query) {

  // We move the options from our options array into where the Solr Service is
  // expecting them.
  $options = array(
    'use_grouping' => TRUE,
    'fields' => isset($this->options['fields']) ? array_keys($this->options['fields']) : array(),
    // Contains also Apache solr specific options.
    'group_sort' => isset($this->options['group_sort']) ? $this->options['group_sort'] : '',
    'group_sort_direction' => isset($this->options['group_sort_direction']) ? $this->options['group_sort_direction'] : 'asc',
    'truncate' => isset($this->options['truncate']) ? $this->options['truncate'] : TRUE,
  );
  $query
    ->setOption('search_api_grouping', $options);
}