You are here

protected function SearchApiElasticsearchBackend::createDateFieldFacet in Elasticsearch Connector 8.6

Same name and namespace in other branches
  1. 8.7 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::createDateFieldFacet()
  2. 8 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::createDateFieldFacet()
  3. 8.2 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::createDateFieldFacet()
  4. 8.5 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::createDateFieldFacet()

Helper function create Facet for date field type.

Parameters

mixed $facet_id:

array $facet:

Return value

array.

1 call to SearchApiElasticsearchBackend::createDateFieldFacet()
SearchApiElasticsearchBackend::addSearchFacets in src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php
Helper function build facets in search.

File

src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php, line 956

Class

SearchApiElasticsearchBackend
Elasticsearch Search API Backend definition.

Namespace

Drupal\elasticsearch_connector\Plugin\search_api\backend

Code

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

  // TODO: Check the timezone cause this hardcoded way doesn't seem 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;
}