Class: Elastic::Nodes::Agg::Terms

Inherits:
BaseAgg show all
Includes:
Concerns::Aggregable, Concerns::Bucketed
Defined in:
lib/elastic/nodes/agg/terms.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.



13
14
15
# File 'lib/elastic/nodes/agg/terms.rb', line 13

def field
  @field
end

#sizeObject

Returns the value of attribute size.



13
14
15
# File 'lib/elastic/nodes/agg/terms.rb', line 13

def size
  @size
end

Class Method Details

.build(_name, _field, size: nil) ⇒ Object



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

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

Instance Method Details

#cloneObject



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

def clone
  prepare_clone(super)
end

#render(_options = {}) ⇒ Object



23
24
25
26
27
28
# File 'lib/elastic/nodes/agg/terms.rb', line 23

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

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

#simplifyObject



19
20
21
# File 'lib/elastic/nodes/agg/terms.rb', line 19

def simplify
  prepare_clone(super)
end