protected function SearchApiElasticsearchConnector::getDateFacetInterval in Elasticsearch Connector 7.5
Same name and namespace in other branches
- 7 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::getDateFacetInterval()
- 7.2 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::getDateFacetInterval()
Helper function which add params to date facets.
1 call to SearchApiElasticsearchConnector::getDateFacetInterval()
- SearchApiElasticsearchConnector::addSearchFacets in modules/
elasticsearch_connector_search_api/ service.inc - Helper function build facets in search.
File
- modules/
elasticsearch_connector_search_api/ service.inc, line 1872 - Provides a Elasticsearch-based service class for the Search API using Elasticsearch Connector module.
Class
- SearchApiElasticsearchConnector
- Search service class.
Code
protected function getDateFacetInterval($facet_id) {
// Active search corresponding to this index.
$searcher = key(facetapi_get_active_searchers());
// Get the FacetApiAdpater for this searcher.
$adapter = isset($searcher) ? facetapi_adapter_load($searcher) : NULL;
$facet = $adapter
->getFacet(array(
'name' => $facet_id,
));
$facet_settings = $facet
->getSettings();
switch ($facet_settings->settings['date_granularity']) {
// Already a selected YEAR, we want the months.
case 'YEAR':
$date_interval = 'month';
break;
// Already a selected MONTH, we want the days.
case 'MONTH':
$date_interval = 'day';
break;
// Already a selected DAY, we want the hours and so on.
case 'DAY':
$date_interval = 'hour';
break;
// By default we return result counts by year.
default:
$date_interval = 'year';
}
return $date_interval;
}