Class: Elastic::Nodes::Agg::DateHistogram

Inherits:
BaseAgg
  • Object
show all
Includes:
Concerns::Aggregable, Concerns::Bucketed
Defined in:
lib/elastic/nodes/agg/date_histogram.rb

Instance Attribute Summary collapse

Attributes inherited from BaseAgg

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Concerns::Bucketed

#handle_result

Methods included from Concerns::Aggregable

#aggregate, #aggregations, #aggregations=, #has_aggregations?, #traverse

Methods inherited from BaseAgg

#initialize

Methods inherited from Base

#==, #handle_result, #traverse

Methods included from Support::Traversable

#pick_nodes, #traverse

Constructor Details

This class inherits a constructor from Elastic::Nodes::BaseAgg

Instance Attribute Details

#fieldObject

Returns the value of attribute field.



14
15
16
# File 'lib/elastic/nodes/agg/date_histogram.rb', line 14

def field
  @field
end

#intervalObject

Returns the value of attribute interval.



15
16
17
# File 'lib/elastic/nodes/agg/date_histogram.rb', line 15

def interval
  @interval
end

#time_zoneObject

Returns the value of attribute time_zone.



15
16
17
# File 'lib/elastic/nodes/agg/date_histogram.rb', line 15

def time_zone
  @time_zone
end

Class Method Details

.build(_name, _field, interval: nil, time_zone: nil) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/elastic/nodes/agg/date_histogram.rb', line 6

def self.build(_name, _field, interval: nil, time_zone: nil)
  super(_name).tap do |node|
    node.field = _field
    node.interval = interval
    node.time_zone = time_zone
  end
end

Instance Method Details

#cloneObject



27
28
29
# File 'lib/elastic/nodes/agg/date_histogram.rb', line 27

def clone
  prepare_clone(super)
end

#render(_options = {}) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/elastic/nodes/agg/date_histogram.rb', line 35

def render(_options = {})
  hash = { 'field' => @field.to_s }
  hash['interval'] = @interval if @interval
  hash['time_zone'] = @time_zone.formatted_offset if @time_zone

  render_aggs({ 'date_histogram' => hash }, _options)
end

#simplifyObject



31
32
33
# File 'lib/elastic/nodes/agg/date_histogram.rb', line 31

def simplify
  prepare_clone(super)
end