protected function SearchApiElasticsearchBackend::getDateFacetInterval in Elasticsearch Connector 8
Same name and namespace in other branches
- 8.7 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::getDateFacetInterval()
- 8.2 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::getDateFacetInterval()
- 8.5 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::getDateFacetInterval()
- 8.6 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::getDateFacetInterval()
Helper function which add params to date facets.
1 call to SearchApiElasticsearchBackend::getDateFacetInterval()
- SearchApiElasticsearchBackend::createDateFieldFacet in src/
Plugin/ search_api/ backend/ SearchApiElasticsearchBackend.php - Helper function create Facet for date field type.
File
- src/
Plugin/ search_api/ backend/ SearchApiElasticsearchBackend.php, line 1308 - Contains the SearchApiElasticsearchBackend object.
Class
- SearchApiElasticsearchBackend
- Plugin annotation @SearchApiBackend( id = "elasticsearch", label = @Translation("Elasticsearch"), description = @Translation("Index items using an Elasticsearch server.") )
Namespace
Drupal\elasticsearch_connector\Plugin\search_api\backendCode
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;
// Get the date granularity.
$date_gap = $this
->getDateGranularity($adapter, $facet_id);
switch ($date_gap) {
// 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;
}