You are here

protected function SearchApiElasticsearchConnector::createDateFieldFacet in Elasticsearch Connector 7

Helper function create Facet for date field type.

1 call to SearchApiElasticsearchConnector::createDateFieldFacet()
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 1795
Provides a Elasticsearch-based service class for the Search API using Elasticsearch Connector module.

Class

SearchApiElasticsearchConnector
Search service class.

Code

protected function createDateFieldFacet($facet_id, $facet) {
  $result = $facet[$facet_id];
  $date_interval = $this
    ->getDateFacetInterval($facet_id);
  $result['date_histogram']['interval'] = $date_interval;

  // TODO: Check the timezone cause this way of hardcoding doesn't seems right.
  $result['date_histogram']['time_zone'] = 'UTC';

  // Use factor 1000 as we store dates as seconds from epoch
  // not milliseconds.
  $result['date_histogram']['factor'] = 1000;
  return $result;
}