Class: JayAPI::Elasticsearch::QueryBuilder::Aggregations::DateHistogram
- Inherits:
-
Aggregation
- Object
- Aggregation
- JayAPI::Elasticsearch::QueryBuilder::Aggregations::DateHistogram
- Defined in:
- lib/jay_api/elasticsearch/query_builder/aggregations/date_histogram.rb
Overview
Represents a date_histogram
aggregation in Elasticsearch. Information about this type of aggregation can be found in: www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-datehistogram-aggregation
Instance Attribute Summary collapse
-
#calendar_interval ⇒ Object
readonly
Returns the value of attribute calendar_interval.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
Attributes inherited from Aggregation
Instance Method Summary collapse
-
#clone ⇒ self
A copy of the receiver.
-
#initialize(name, field:, calendar_interval:, format: nil) ⇒ DateHistogram
constructor
A new instance of DateHistogram.
-
#to_h(&block) ⇒ Hash
The Hash representation of the
Aggregation
.
Methods inherited from Aggregation
Constructor Details
#initialize(name, field:, calendar_interval:, format: nil) ⇒ DateHistogram
Returns a new instance of DateHistogram.
24 25 26 27 28 29 |
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/date_histogram.rb', line 24 def initialize(name, field:, calendar_interval:, format: nil) @field = field @calendar_interval = calendar_interval @format = format super(name) end |
Instance Attribute Details
#calendar_interval ⇒ Object (readonly)
Returns the value of attribute calendar_interval.
11 12 13 |
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/date_histogram.rb', line 11 def calendar_interval @calendar_interval end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
11 12 13 |
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/date_histogram.rb', line 11 def field @field end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
11 12 13 |
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/date_histogram.rb', line 11 def format @format end |
Instance Method Details
#clone ⇒ self
Returns A copy of the receiver.
32 33 34 35 36 |
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/date_histogram.rb', line 32 def clone self.class.new(name, field: field, calendar_interval: calendar_interval, format: format).tap do |copy| copy.aggregations = aggregations.clone end end |
#to_h(&block) ⇒ Hash
Returns The Hash representation of the Aggregation
. Properly formatted for Elasticsearch.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/date_histogram.rb', line 40 def to_h(&block) super do { date_histogram: { field: field, calendar_interval: calendar_interval, format: format }.compact } end end |