Class: JayAPI::Elasticsearch::QueryBuilder::Aggregations::Max

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

Overview

Represents a max aggregation in Elasticsearch. Information on this type of aggregation can be found here: www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-max-aggregation.html

Instance Attribute Summary collapse

Attributes inherited from Aggregation

#name

Instance Method Summary collapse

Constructor Details

#initialize(name, field:) ⇒ Max

Returns a new instance of Max.

Parameters:

  • name (String)

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

  • field (String)

    The field whose values should be added-up



18
19
20
21
22
23
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/max.rb', line 18

def initialize(name, field:)
  super(name)

  @field = field
  @missing = missing
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



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

def field
  @field
end

#missingObject (readonly)

Returns the value of attribute missing.



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

def missing
  @missing
end

Instance Method Details

#aggsObject

Raises:



27
28
29
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/max.rb', line 27

def aggs
  no_nested_aggregations('Max')
end

#cloneself

Returns A copy of the receiver.

Returns:

  • (self)

    A copy of the receiver.



32
33
34
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/max.rb', line 32

def clone
  self.class.new(name, field: field)
end

#to_hHash

Returns The Hash representation of the Aggregation. Properly formatted for Elasticsearch.

Returns:

  • (Hash)

    The Hash representation of the Aggregation. Properly formatted for Elasticsearch.



38
39
40
41
42
43
44
45
46
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/max.rb', line 38

def to_h
  super do
    {
      max: {
        field: field
      }
    }
  end
end