class Elastic::Shims::SingleAggregation

Public Instance Methods

handle_result(_raw, _formatter) click to toggle source
Calls superclass method Elastic::Shims::Base#handle_result
# File lib/elastic/shims/single_aggregation.rb, line 3
def handle_result(_raw, _formatter)
  result = super

  case result
  when Elastic::Results::Root
    result.aggregations.first.last.as_value
  when Elastic::Results::GroupedResult
    result.map_to_group { |b| b.first.last }
  else
    raise "unable to reduce result of type #{result.class}"
  end
end