Class: Arelastic::Searches::Aggregations

Inherits:
Search show all
Defined in:
lib/arelastic/searches/aggregations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Nodes::Node

#==, #convert_to_elastic

Methods included from Arities::Binary

#binary

Methods included from Arities::Polyadic

#polyadic

Methods included from Arities::Unary

#unary

Constructor Details

#initialize(*aggregations) ⇒ Aggregations

Returns a new instance of Aggregations.



5
6
7
# File 'lib/arelastic/searches/aggregations.rb', line 5

def initialize *aggregations
  @aggregations = aggregations.flatten
end

Instance Attribute Details

#aggregationsObject

Returns the value of attribute aggregations.



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

def aggregations
  @aggregations
end

Instance Method Details

#as_elasticObject



9
10
11
12
# File 'lib/arelastic/searches/aggregations.rb', line 9

def as_elastic
  grouping = Arelastic::Nodes::HashGroup.new aggregations.flatten
  { "aggs" => grouping.as_elastic }
end

#nested(name, path) ⇒ Object



14
15
16
# File 'lib/arelastic/searches/aggregations.rb', line 14

def nested(name, path)
  Arelastic::Aggregations::Nested.new name, path, aggregations
end