public function ApacheSolrFacetapiNumericRange::execute in Apache Solr Search 7
Same name and namespace in other branches
- 8 plugins/facetapi/query_type_numeric_range.inc \ApacheSolrFacetapiNumericRange::execute()
- 6.3 plugins/facetapi/query_type_numeric_range.inc \ApacheSolrFacetapiNumericRange::execute()
Adds the filter to the query object.
@todo Cache the values based on the filter query or any other way?
Parameters
DrupalSolrQueryInterface $query: An object containing the query in the backend's native API.
File
- plugins/
facetapi/ query_type_numeric_range.inc, line 31 - Numeric range query type plugin for the Apache Solr adapter.
Class
- ApacheSolrFacetapiNumericRange
- Plugin for "numeric_range" query types.
Code
public function execute($query) {
// Check if we have a cache of this field
//
$settings = $this->adapter
->getFacet($this->facet)
->getSettings();
$active = $this->adapter
->getActiveItems($this->facet);
$singular_field_info = $this->facet['map options'];
$singular_field_info['multiple'] = FALSE;
$this->single_key = apachesolr_index_key($singular_field_info);
// See: http://wiki.apache.org/solr/StatsComponent
$query
->addParam('stats', 'true');
$query
->addParam('stats.field', $this->single_key);
$query
->addParam('stats.facet', $this->single_key);
// Range filters don't support OR operator.
foreach ($active as $value => $item) {
$query
->addFilter($this->single_key, $value);
}
}