Class: JayAPI::Elasticsearch::QueryBuilder::Aggregations::ValueCount

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

Overview

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

Instance Attribute Summary collapse

Attributes inherited from Aggregation

#name

Instance Method Summary collapse

Constructor Details

#initialize(name, field:) ⇒ ValueCount

Returns a new instance of ValueCount.

Parameters:

  • field (String)

    The whose non-empty values should be counted.



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

def initialize(name, field:)
  @field = field
  super(name)
end

Instance Attribute Details

#fieldObject (readonly)

TODO: Add script support to the aggregation



15
16
17
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/value_count.rb', line 15

def field
  @field
end

Instance Method Details

#aggsObject

Raises:



26
27
28
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/value_count.rb', line 26

def aggs
  no_nested_aggregations('Value Count')
end

#cloneself

Returns A copy of the receiver.

Returns:

  • (self)

    A copy of the receiver.



31
32
33
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/value_count.rb', line 31

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.



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

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