You are here

protected function Solr_Base_Query::rebuild_fq in Apache Solr Search 6.2

Same name and namespace in other branches
  1. 5.2 Solr_Base_Query.php \Solr_Base_Query::rebuild_fq()
  2. 6 Solr_Base_Query.php \Solr_Base_Query::rebuild_fq()

Builds a set of filter queries from $this->fields and all subqueries.

Returns an array of strings that can be combined into a URL query parameter or passed to Solr as fq paramters.

1 call to Solr_Base_Query::rebuild_fq()
Solr_Base_Query::get_fq in ./Solr_Base_Query.php

File

./Solr_Base_Query.php, line 461

Class

Solr_Base_Query

Code

protected function rebuild_fq($aliases = FALSE) {
  $fq = array();
  $fields = array();
  foreach ($this->fields as $pos => $field) {

    // Look for a field alias.
    if ($aliases && isset($this->field_map[$field['#name']])) {
      $field['#name'] = $this->field_map[$field['#name']];
    }
    $fq[$field['#name']][] = $this
      ->make_filter($field);
  }
  foreach ($this->subqueries as $id => $data) {
    $subfq = $data['#query']
      ->rebuild_fq($aliases);
    if ($subfq) {
      $operator = $data['#fq_operator'];
      $subqueries = array();
      foreach ($subfq as $key => $values) {
        foreach ($values as $value) {
          $subqueries[] = $value;
        }
      }
      $fq['subqueries'][$id] = " (" . implode(" {$operator} ", $subqueries) . ")";
    }
  }
  return $fq;
}