Class: Elasticated::GroupAggregation
- Inherits:
-
TermsAggregation
- Object
- Aggregation
- TermsAggregation
- Elasticated::GroupAggregation
- Includes:
- Subaggregated
- Defined in:
- lib/elasticated/aggregations/group_aggregation.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes included from Subaggregated
Attributes inherited from TermsAggregation
#order_field, #order_method, #size
Attributes inherited from Aggregation
#alias_name, #extra_params, #field
Instance Method Summary collapse
- #build ⇒ Object
- #default_name ⇒ Object
-
#initialize(field, *args, &block) ⇒ GroupAggregation
constructor
A new instance of GroupAggregation.
- #parse(response) ⇒ Object
Methods included from Subaggregated
Methods inherited from Aggregation
Methods included from Clonable
Methods included from BlockEvaluation
Constructor Details
#initialize(field, *args, &block) ⇒ GroupAggregation
Returns a new instance of GroupAggregation.
5 6 7 8 |
# File 'lib/elasticated/aggregations/group_aggregation.rb', line 5 def initialize(field, *args, &block) super initialize_subaggregations &block end |
Instance Method Details
#build ⇒ Object
14 15 16 17 18 |
# File 'lib/elasticated/aggregations/group_aggregation.rb', line 14 def build aggregation_struct = super aggregation_struct.merge! build_subaggregations aggregation_struct end |
#default_name ⇒ Object
10 11 12 |
# File 'lib/elasticated/aggregations/group_aggregation.rb', line 10 def default_name "group_by_#{field}" end |
#parse(response) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/elasticated/aggregations/group_aggregation.rb', line 20 def parse(response) response['buckets'].inject({}) do |hash, bucket| bucket_hash = { 'count' => bucket['doc_count'] } bucket_hash.merge! parse_subaggregations(bucket) hash.merge bucket['key'] => bucket_hash end end |