Class: Arelastic::Aggregations::Nested

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

Instance Attribute Summary collapse

Attributes inherited from Aggregation

#name, #options

Instance Method Summary collapse

Methods inherited from Aggregation

#as_elastic_aggregation, #nested

Methods inherited from Nodes::Node

#==, #convert_to_elastic

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, path, aggregations) ⇒ Nested

HashGroup



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

def initialize name, path, aggregations
  super name
  @path = path
  @aggregations = aggregations
end

Instance Attribute Details

#aggregationsObject

Returns the value of attribute aggregations.



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

def aggregations
  @aggregations
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#as_elasticObject



13
14
15
16
17
18
19
20
21
# File 'lib/arelastic/aggregations/nested.rb', line 13

def as_elastic
  grouping = Arelastic::Nodes::HashGroup.new aggregations
  {
    name => {
      "nested" => {"path" => path},
      "aggs"   => grouping.as_elastic
    }
  }
end