public function SolrFilterSubQuery::makeFilterQuery in Apache Solr Search 7
Same name and namespace in other branches
- 8 Solr_Base_Query.php \SolrFilterSubQuery::makeFilterQuery()
- 6.3 Solr_Base_Query.php \SolrFilterSubQuery::makeFilterQuery()
1 call to SolrFilterSubQuery::makeFilterQuery()
- SolrFilterSubQuery::rebuildFq in ./
Solr_Base_Query.php - Builds a set of filter queries from $this->fields and all subqueries.
File
- ./
Solr_Base_Query.php, line 125 - 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
public function makeFilterQuery(array $filter) {
$prefix = empty($filter['#exclude']) ? '' : '-';
if ($filter['#local']) {
$prefix = '{!' . $filter['#local'] . '}' . $prefix;
}
// If the field value contains a colon or a space, wrap it in double quotes,
// unless it is a range query or is already wrapped in double quotes or
// parentheses.
if (preg_match('/[ :]/', $filter['#value']) && !preg_match('/^[\\[\\{]\\S+ TO \\S+[\\]\\}]$/', $filter['#value']) && !preg_match('/^["\\(].*["\\)]$/', $filter['#value'])) {
$filter['#value'] = '"' . $filter['#value'] . '"';
}
return $prefix . $filter['#name'] . ':' . $filter['#value'];
}