Module: Elastic::Nodes::Concerns::Bucketed

Included in:
Agg::DateHistogram, Agg::Terms
Defined in:
lib/elastic/nodes/concerns/bucketed.rb

Instance Method Summary collapse

Instance Method Details

#handle_result(_raw, _formatter) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/elastic/nodes/concerns/bucketed.rb', line 3

def handle_result(_raw, _formatter)
  buckets = _raw['buckets'].map do |raw_bucket|
    key = _formatter.format_field(field, raw_bucket['key'])
    aggs = load_aggs_results(raw_bucket, _formatter)

    Elastic::Results::Bucket.new(key, raw_bucket['doc_count'], aggs)
  end

  Elastic::Results::BucketCollection.new buckets
end