Commit 70323f4a authored by RajeevK's avatar RajeevK Committed by borisson_

Issue #2929144 by RajeevK, nchar, borisson_: Add granularity to facet query...

Issue #2929144 by RajeevK, nchar, borisson_: Add granularity to facet query options for numeric granular query types
parent a542b87b
......@@ -38,6 +38,15 @@ class SearchApiGranular extends QueryTypeRangeBase {
];
}
/**
* {@inheritdoc}
*/
protected function getFacetOptions() {
return parent::getFacetOptions() + [
'granularity' => $this->getGranularity(),
];
}
/**
* Looks at the configuration for this facet to determine the granularity.
*
......
......@@ -31,13 +31,7 @@ class SearchApiRange extends QueryTypePluginBase {
// Set the options for the actual query.
$options = &$query->getOptions();
$options['search_api_facets'][$field_identifier] = [
'field' => $field_identifier,
'limit' => $this->facet->getHardLimit(),
'operator' => $this->facet->getQueryOperator(),
'min_count' => $this->facet->getMinCount(),
'missing' => FALSE,
];
$options['search_api_facets'][$field_identifier] = $this->getFacetOptions();
// Add the filter to the query if there are active values.
$active_items = $this->facet->getActiveItems();
......
......@@ -36,13 +36,7 @@ class SearchApiString extends QueryTypePluginBase {
// Set the options for the actual query.
$options = &$query->getOptions();
$options['search_api_facets'][$field_identifier] = [
'field' => $field_identifier,
'limit' => $this->facet->getHardLimit(),
'operator' => $this->facet->getQueryOperator(),
'min_count' => $this->facet->getMinCount(),
'missing' => FALSE,
];
$options['search_api_facets'][$field_identifier] = $this->getFacetOptions();
// Add the filter to the query if there are active values.
$active_items = $this->facet->getActiveItems();
......
......@@ -80,4 +80,20 @@ abstract class QueryTypePluginBase extends PluginBase implements QueryTypeInterf
return $this->dependencies;
}
/**
* Builds facet options that will be send to the backend.
*
* @return array
* An array of default options for the facet.
*/
protected function getFacetOptions() {
return [
'field' => $this->facet->getFieldIdentifier(),
'limit' => $this->facet->getHardLimit(),
'operator' => $this->facet->getQueryOperator(),
'min_count' => $this->facet->getMinCount(),
'missing' => FALSE,
];
}
}
......@@ -22,13 +22,7 @@ abstract class QueryTypeRangeBase extends QueryTypePluginBase {
$operator = $this->facet->getQueryOperator();
$field_identifier = $this->facet->getFieldIdentifier();
$exclude = $this->facet->getExclude();
$options['search_api_facets'][$field_identifier] = [
'field' => $field_identifier,
'limit' => $this->facet->getHardLimit(),
'operator' => $this->facet->getQueryOperator(),
'min_count' => $this->facet->getMinCount(),
'missing' => FALSE,
];
$options['search_api_facets'][$field_identifier] = $this->getFacetOptions();
// Add the filter to the query if there are active values.
$active_items = $this->facet->getActiveItems();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment