Class: Arelastic::Aggregations::Aggregation

Inherits:
Nodes::Node
  • Object
show all
Defined in:
lib/arelastic/aggregations/aggregation.rb

Direct Known Subclasses

Bucket, BucketSelector, BucketSort, Cardinality, Max, Min, Sum, ValueCount

Instance Attribute Summary collapse

Instance Method Summary collapse

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 = {}) ⇒ Aggregation

Returns a new instance of Aggregation.



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

def initialize(name, options = {})
  @name    = name

  options  = options.dup
  @meta    = read_option! options, 'meta'
  @options = options
end

Instance Attribute Details

#metaObject

Returns the value of attribute meta.



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

def meta
  @meta
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#as_elasticObject



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

def as_elastic
  params = as_elastic_aggregation
  params['meta'] = meta if meta
  {name => params}
end

#nested(path) ⇒ Object



20
21
22
# File 'lib/arelastic/aggregations/aggregation.rb', line 20

def nested(path)
  Arelastic::Aggregations::Nested.new(name, path, [self])
end

#reverse_nested(path = nil) ⇒ Object



24
25
26
# File 'lib/arelastic/aggregations/aggregation.rb', line 24

def reverse_nested(path = nil)
  Arelastic::Aggregations::ReverseNested.new(name, path, [self])
end