Class: Elasticated::NestedAggregation

Inherits:
Aggregation show all
Includes:
Subaggregated
Defined in:
lib/elasticated/aggregations/nested_aggregation.rb

Instance Attribute Summary collapse

Attributes included from Subaggregated

#_subaggregations

Attributes inherited from Aggregation

#alias_name, #extra_params, #field

Instance Method Summary collapse

Methods included from Subaggregated

#initialize_subaggregations

Methods inherited from Aggregation

#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

#initialize(path, *args, &block) ⇒ NestedAggregation

Returns a new instance of NestedAggregation.



7
8
9
10
11
# File 'lib/elasticated/aggregations/nested_aggregation.rb', line 7

def initialize(path, *args, &block)
  self.path = path
  super
  initialize_subaggregations &block
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/elasticated/aggregations/nested_aggregation.rb', line 5

def path
  @path
end

Instance Method Details

#buildObject



17
18
19
20
21
# File 'lib/elasticated/aggregations/nested_aggregation.rb', line 17

def build
  body = { nested: { path: path } }
  body.merge! build_subaggregations
  body
end

#default_nameObject



13
14
15
# File 'lib/elasticated/aggregations/nested_aggregation.rb', line 13

def default_name
  path
end

#parse(response) ⇒ Object



23
24
25
26
27
# File 'lib/elasticated/aggregations/nested_aggregation.rb', line 23

def parse(response)
  ret = { 'count' => response['doc_count'] }
  ret.merge! parse_subaggregations(response)
  ret
end