Class: Arelastic::Aggregations::Bucket

Inherits:
Aggregation show all
Defined in:
lib/arelastic/aggregations/bucket.rb

Instance Attribute Summary collapse

Attributes inherited from Aggregation

#meta, #name, #options

Instance Method Summary collapse

Methods inherited from Aggregation

#as_elastic, #nested, #reverse_nested

Methods inherited from Nodes::Node

#==, #convert_to_elastic, #hash, #read_option!

Methods included from Arelastic::Arities::Binary

#binary

Methods included from Arelastic::Arities::Polyadic

#polyadic

Methods included from Arelastic::Arities::Unary

#unary

Constructor Details

#initialize(name, options = {}) ⇒ Bucket

Returns a new instance of Bucket.



6
7
8
9
10
# File 'lib/arelastic/aggregations/bucket.rb', line 6

def initialize(name, options = {})
  options = options.dup
  @aggs = read_option! options, 'aggs'
  super(name, options)
end

Instance Attribute Details

#aggsObject

Returns the value of attribute aggs.



4
5
6
# File 'lib/arelastic/aggregations/bucket.rb', line 4

def aggs
  @aggs
end

Instance Method Details

#as_elastic_aggregationObject



12
13
14
15
16
17
18
# File 'lib/arelastic/aggregations/bucket.rb', line 12

def as_elastic_aggregation
  if aggs
    {'aggs' => Arelastic::Nodes::HashGroup.new(aggs).as_elastic}
  else
    {}
  end
end