Class: Elastic::Shims::TotalPicking

Inherits:
Base
  • Object
show all
Defined in:
lib/elastic/shims/total_picking.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/total_picking.rb', line 3

def handle_result(_raw, _formatter)
  result = super

  case result
  when Elastic::Results::Root
    result.total
  when Elastic::Results::GroupedResult
    result.map_to_group { |bucket| Elastic::Results::Metric.new(bucket.total) }
  else
    raise "unable to pick from result of type #{result.class}"
  end
end