You are here

protected function SolrFilterSubQuery::rebuildFq in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 Solr_Base_Query.php \SolrFilterSubQuery::rebuildFq()
  2. 6.3 Solr_Base_Query.php \SolrFilterSubQuery::rebuildFq()

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.

2 calls to SolrFilterSubQuery::rebuildFq()
SolrBaseQuery::getParam in ./Solr_Base_Query.php
Gets the value of a parameter.
SolrBaseQuery::getParams in ./Solr_Base_Query.php
Gets all parameters in normalized form.

File

./Solr_Base_Query.php, line 240
This class allows you to make operations on a query that will be sent to Apache Solr. methods such as adding and removing sorts, remove and replace parameters, adding and removing filters, getters and setters for various parameters and more

Class

SolrFilterSubQuery
This class allows you to make operations on a query that will be sent to Apache Solr. methods such as adding and removing sorts, remove and replace parameters, adding and removing filters, getters and setters for various parameters and…

Code

protected function rebuildFq() {
  $fq = array();
  foreach ($this->fields as $pos => $field) {
    $fq[] = $this
      ->makeFilterQuery($field);
  }
  foreach ($this->subqueries as $subquery) {
    $subfq = $subquery
      ->rebuildFq();
    if ($subfq) {
      $operator = $subquery->operator;
      $prefix = $subquery->exclude ? '-' : '';
      $fq[] = "{$prefix}(" . implode(" {$operator} ", $subfq) . ")";
    }
  }
  return $fq;
}