protected function SearchApiElasticsearchElastica::createDateFieldAggregation in Search API Elasticsearch 7
1 call to SearchApiElasticsearchElastica::createDateFieldAggregation()
- SearchApiElasticsearchElastica::addSearchAggregation in modules/
elastica/ includes/ SearchApiElasticsearchElastica.inc - Helper function build Aggregations in search.
File
- modules/
elastica/ includes/ SearchApiElasticsearchElastica.inc, line 765 - Provides Elastica client for Search API Elasticsearch.
Class
- SearchApiElasticsearchElastica
- Search API Elasticsearch Elastica service class.
Code
protected function createDateFieldAggregation($agg_id) {
$date_interval = $this
->getDateAggregationInterval($agg_id);
$agg = new Elastica\Aggregation\DateRange($agg_id);
$agg
->setField($agg_id);
$agg
->addRange(strtotime('-1 day'), time(), '1 Day');
$agg
->addRange(strtotime('-7 day'), time(), '1 Weeks');
$agg
->addRange(strtotime('-14 day'), time(), '2 Weeks');
$agg
->addRange(strtotime('-21 day'), time(), '3 Weeks');
$agg
->addRange(strtotime('-365 day'), time(), 'All time');
$agg
->setFormat("dd MM yyyy");
return $agg;
}