Class: Aggregations::Buckets::HistogramAggregationBuilder

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

Overview

Elasticsearch Histogram Aggregation

Constant Summary collapse

ATTRIBUTES =
[:order, :interval, :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:) ⇒ HistogramAggregationBuilder

Returns a new instance of HistogramAggregationBuilder.

Parameters:

  • name (String)

    : Aggregation name



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

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

Instance Method Details

#add_order(bucket_order) ⇒ HistogramAggregationBuilder

Returns , can be chained for ordering on multiple fields.

Parameters:

Returns:



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

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

#interval(interval) ⇒ HistogramAggregationBuilder

Parameters:

  • interval (String)

Returns:



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

def interval interval
  @interval = interval
  self
end

#interval_exprString

Returns:

  • (String)


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

def interval_expr
  @interval
end

#min_doc_count(doc_count) ⇒ HistogramAggregationBuilder

Parameters:

  • doc_count (Integer)

Returns:



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

def min_doc_count doc_count
  @min_doc_count = doc_count
  self
end

#min_doc_count_exprInteger

Returns:

  • (Integer)


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

def min_doc_count_expr
  @min_doc_count
end

#order_exprArray

Returns:

  • (Array)


33
34
35
# File 'lib/aggregations/buckets/histogram_aggregation_builder.rb', line 33

def order_expr
  @order
end