lib/elastic/shims/reducing.rb in elastic-rails-0.5.0 vs lib/elastic/shims/reducing.rb in elastic-rails-0.6.0
- old
+ new
@@ -1,20 +1,16 @@
module Elastic::Shims
class Reducing < Base
- def handle_result(_raw)
+ def handle_result(_raw, _formatter)
result = super
case result
when Elastic::Results::Root
result.aggregations.first.last.as_value
when Elastic::Results::GroupedResult
- groups = result.map do |keys, bucket|
- Elastic::Results::ResultGroup.new keys, bucket.first.last
- end
-
- Elastic::Results::GroupedResult.new groups
+ result.map_to_group { |b| b.first.last }
else
- result
+ raise "unable to reduce result of type #{result.class}"
end
end
end
end