Class: Aggregations::Buckets::TermsAggregationBuilder

Inherits:
Object
  • Object
show all
Includes:
Helpers::AbstractAggregationHelper, Helpers::AggregationQueryBuilderHelper, Helpers::ValuesSourceAggregationHelper, AttributesReader
Defined in:
lib/aggregations/buckets/terms_aggregation_builder.rb

Overview

Elasticsearch Terms Aggregation

Constant Summary collapse

ATTRIBUTES =
[:size, :order, :include, :exclude, :min_doc_count]

Constants included from Helpers::AggregationQueryBuilderHelper

Helpers::AggregationQueryBuilderHelper::OBJECT_ARRAY_QUERY_FIELDS, Helpers::AggregationQueryBuilderHelper::OBJECT_ARRAY_SETTINGS_FIELDS

Instance Method Summary collapse

Methods included from AttributesReader

#attributes

Methods included from Helpers::AggregationQueryBuilderHelper

#name_expr, #query, #type_expr

Methods included from Helpers::AbstractAggregationHelper

#abstract_agg_builder, #sub_aggregation, #sub_aggregation_expr

Methods included from Helpers::ValuesSourceAggregationHelper

#field, #field_expr, #missing, #missing_expr, #script, #script_expr, #value_source_agg_builder

Constructor Details

#initialize(name:) ⇒ TermsAggregationBuilder

Returns a new instance of TermsAggregationBuilder.

Parameters:

  • name (String)

    : Aggregation name



14
15
16
17
18
19
20
21
22
# File 'lib/aggregations/buckets/terms_aggregation_builder.rb', line 14

def initialize name:
  @name = name.intern
  @type = :terms
  @query = {
    @name => {
      @type => {}
    }
  }
end

Instance Method Details

#add_order(bucket_order) ⇒ TermsAggregationBuilder

Returns , can be chained for ordering on multiple fields.

Parameters:

Returns:



38
39
40
41
42
# File 'lib/aggregations/buckets/terms_aggregation_builder.rb', line 38

def add_order bucket_order
  @order ||= []
  @order << bucket_order
  self
end

#exclude(exclude_list) ⇒ TermsAggregationBuilder

Parameters:

  • exclude (Array)

    list

Returns:



63
64
65
66
# File 'lib/aggregations/buckets/terms_aggregation_builder.rb', line 63

def exclude exclude_list
  @exclude = exclude_list
  self
end

#exclude_exprArray

Returns:

  • (Array)


69
70
71
# File 'lib/aggregations/buckets/terms_aggregation_builder.rb', line 69

def exclude_expr
  @exclude
end

#include(include_list) ⇒ TermsAggregationBuilder

Parameters:

  • include (Array)

    list

Returns:



51
52
53
54
# File 'lib/aggregations/buckets/terms_aggregation_builder.rb', line 51

def include include_list
  @include = include_list
  self
end

#include_exprArray

Returns:

  • (Array)


57
58
59
# File 'lib/aggregations/buckets/terms_aggregation_builder.rb', line 57

def include_expr
  @include
end

#min_doc_count(doc_count) ⇒ TermsAggregationBuilder

Parameters:

  • min (Integer)

    doc count

Returns:



75
76
77
78
# File 'lib/aggregations/buckets/terms_aggregation_builder.rb', line 75

def min_doc_count doc_count
  @min_doc_count = doc_count
  self
end

#min_doc_count_exprInteger

Returns:

  • (Integer)


81
82
83
# File 'lib/aggregations/buckets/terms_aggregation_builder.rb', line 81

def min_doc_count_expr
  @min_doc_count
end

#order_exprArray

Returns:

  • (Array)


45
46
47
# File 'lib/aggregations/buckets/terms_aggregation_builder.rb', line 45

def order_expr
  @order
end

#size(size) ⇒ TermsAggregationBuilder

Parameters:

  • size (Integer)

Returns:



26
27
28
29
# File 'lib/aggregations/buckets/terms_aggregation_builder.rb', line 26

def size size
  @size = size
  self
end

#size_exprInteger

Returns:

  • (Integer)


32
33
34
# File 'lib/aggregations/buckets/terms_aggregation_builder.rb', line 32

def size_expr
  @size
end