Class: Elastic::Shims::SingleAggregation

Inherits:
Base
  • Object
show all
Defined in:
lib/elastic/shims/single_aggregation.rb

Instance Attribute Summary

Attributes inherited from Base

#child

Instance Method Summary collapse

Methods inherited from Base

#initialize, #render, #traverse

Methods included from Elastic::Support::Traversable

#pick_nodes, #traverse

Constructor Details

This class inherits a constructor from Elastic::Shims::Base

Instance Method Details

#handle_result(_raw, _formatter) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# 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