Class: Elasticated::CountAggregation

Inherits:
TermsAggregation show all
Defined in:
lib/elasticated/aggregations/count_aggregation.rb

Instance Attribute Summary

Attributes inherited from TermsAggregation

#order_field, #order_method, #size

Attributes inherited from Aggregation

#alias_name, #extra_params, #field

Instance Method Summary collapse

Methods inherited from TermsAggregation

#build, #initialize

Methods inherited from Aggregation

#initialize, #name, #original_name

Methods included from Clonable

#==, #clone

Methods included from BlockEvaluation

#evaluate

Constructor Details

This class inherits a constructor from Elasticated::TermsAggregation

Instance Method Details

#default_nameObject



4
5
6
# File 'lib/elasticated/aggregations/count_aggregation.rb', line 4

def default_name
  "count_by_#{field}"
end

#parse(response) ⇒ Object



8
9
10
11
12
# File 'lib/elasticated/aggregations/count_aggregation.rb', line 8

def parse(response)
  response['buckets'].inject({}) do |hash, bucket|
    hash.merge bucket['key'] => bucket['doc_count']
  end
end