Class: JayAPI::Elasticsearch::QueryBuilder::Aggregations::Aggregation

Inherits:
Object
  • Object
show all
Defined in:
lib/jay_api/elasticsearch/query_builder/aggregations/aggregation.rb

Overview

Base class for all Elasticsearch aggregation types. For more information on what types of aggregations are available see: www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Aggregation

Returns a new instance of Aggregation.

Parameters:

  • name (String)

    The name used by Elasticsearch to identify each of the aggregations.



17
18
19
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/aggregation.rb', line 17

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/aggregation.rb', line 13

def name
  @name
end

Instance Method Details

#aggs {|The| ... } ⇒ JayAPI::Elasticsearch::QueryBuilder::Aggregations, self

Creates nested aggregations inside the receiver.

Yield Parameters:

Returns:



28
29
30
31
32
33
34
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/aggregation.rb', line 28

def aggs(&block)
  aggregations = self.aggregations ||= ::JayAPI::Elasticsearch::QueryBuilder::Aggregations.new
  return aggregations unless block

  block.call(aggregations)
  self
end

#cloneObject

Raises:

  • (NotImplementedError)

    Is always raised. The child classes must override the method.



38
39
40
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/aggregation.rb', line 38

def clone
  raise NotImplementedError, "Please implement #{__method__} in #{self.class}"
end