class Elastic::Nodes::Agg::Top
Attributes
field[RW]
Public Class Methods
build(_name, _field, _options = {})
click to toggle source
Calls superclass method
Elastic::Nodes::BaseAgg::build
# File lib/elastic/nodes/agg/top.rb, line 5 def self.build(_name, _field, _options = {}) super(_name).tap do |node| node.field = _field end end
Public Instance Methods
clone()
click to toggle source
Calls superclass method
Elastic::Nodes::Concerns::Sortable#clone
# File lib/elastic/nodes/agg/top.rb, line 13 def clone prepare_clone super end
handle_result(_raw, _formatter)
click to toggle source
# File lib/elastic/nodes/agg/top.rb, line 28 def handle_result(_raw, _formatter) hit = _raw['hits']['hits'].first raw_value = hit ? hit['_source'][@field.to_s] : nil # TODO: apply formatter to value Elastic::Results::Metric.new raw_value end
render(_options = {})
click to toggle source
# File lib/elastic/nodes/agg/top.rb, line 21 def render(_options = {}) top_hit_config = { '_source' => { 'includes' => [@field.to_s] }, 'size' => 1 } top_hit_config['sort'] = render_sorts if registered_sorts.count > 0 { 'top_hits' => top_hit_config } end
simplify()
click to toggle source
Calls superclass method
Elastic::Nodes::Concerns::Sortable#simplify
# File lib/elastic/nodes/agg/top.rb, line 17 def simplify prepare_clone super end
Private Instance Methods
prepare_clone(_clone)
click to toggle source
# File lib/elastic/nodes/agg/top.rb, line 38 def prepare_clone(_clone) _clone.field = @field _clone end