Class: Elasticated::RangeAggregation
Instance Attribute Summary collapse
#_subaggregations
Attributes inherited from Aggregation
#alias_name, #extra_params, #field
Instance Method Summary
collapse
#initialize_subaggregations
Methods inherited from Aggregation
#name, #original_name
Methods included from Clonable
#==, #clone
#evaluate
Constructor Details
#initialize(field, *args, &block) ⇒ RangeAggregation
7
8
9
10
|
# File 'lib/elasticated/aggregations/range_aggregation.rb', line 7
def initialize(field, *args, &block)
super
initialize_subaggregations RangeAggregationEvaluator.new, &block
end
|
Instance Attribute Details
#_conditions ⇒ Object
Returns the value of attribute _conditions.
5
6
7
|
# File 'lib/elasticated/aggregations/range_aggregation.rb', line 5
def _conditions
@_conditions
end
|
Instance Method Details
#build ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/elasticated/aggregations/range_aggregation.rb', line 16
def build
ranges = _subaggregations.build_ranges
body_struct = { field: field, keyed: true, ranges: ranges }
body_struct.merge!
body = { range: body_struct }
body.merge! build_subaggregations
body
end
|
#default_name ⇒ Object
12
13
14
|
# File 'lib/elasticated/aggregations/range_aggregation.rb', line 12
def default_name
"range_over_#{field}"
end
|
#parse(response) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/elasticated/aggregations/range_aggregation.rb', line 26
def parse(response)
response['buckets'].inject({}) do |hash, (key_name, values)|
range_body = { 'count' => values['doc_count'] }
range_body.merge! parse_subaggregations(values)
hash.merge key_name => range_body
end
end
|