Class: Elasticated::SingleValueAggregation

Inherits:
Aggregation
  • Object
show all
Defined in:
lib/elasticated/aggregations/single_value_aggregation.rb

Instance Attribute Summary

Attributes inherited from Aggregation

#alias_name, #extra_params, #field

Instance Method Summary collapse

Methods inherited from Aggregation

#initialize, #name, #original_name

Methods included from Mixins::Inspectionable

#inspect, #text_for_inspect

Methods included from Mixins::BlockEvaluation

#evaluate

Methods included from Mixins::Clonable

#==, #clone

Constructor Details

This class inherits a constructor from Elasticated::Aggregation

Instance Method Details

#buildObject



11
12
13
14
15
# File 'lib/elasticated/aggregations/single_value_aggregation.rb', line 11

def build
  operation_info = { field: field }
  operation_info.merge! extra_params
  { operation => operation_info }
end

#default_nameObject

abstract class child must implement operation()



7
8
9
# File 'lib/elasticated/aggregations/single_value_aggregation.rb', line 7

def default_name
  "#{operation}_#{field}"
end

#parse(response) ⇒ Object



17
18
19
# File 'lib/elasticated/aggregations/single_value_aggregation.rb', line 17

def parse(response)
  response[result_key] || 0
end