Class: Aggregations::Buckets::TopHitsAggregationBuilder

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

Overview

Elasticsearch Top Hits Aggregation

Constant Summary collapse

ATTRIBUTES =
[:size, :sort, :_source]

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

Constructor Details

#initialize(name:) ⇒ TopHitsAggregationBuilder

Returns a new instance of TopHitsAggregationBuilder.

Parameters:

  • name (String)

    : Aggregation name



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

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

Instance Method Details

#add_sort(sort) ⇒ TopHitsAggregationBuilder

Parameters:

Returns:



37
38
39
40
41
# File 'lib/aggregations/buckets/top_hits_aggregation_builder.rb', line 37

def add_sort sort
  @sort ||= []
  @sort << sort
  self
end

#size(size) ⇒ TopHitsAggregationBuilder

Parameters:

  • size (Integer)

Returns:



25
26
27
28
# File 'lib/aggregations/buckets/top_hits_aggregation_builder.rb', line 25

def size size
  @size = size
  self
end

#size_exprInteger

Returns:

  • (Integer)


31
32
33
# File 'lib/aggregations/buckets/top_hits_aggregation_builder.rb', line 31

def size_expr
  @size
end

#sort_exprSort::SortBuilder

Returns:



44
45
46
# File 'lib/aggregations/buckets/top_hits_aggregation_builder.rb', line 44

def sort_expr
  @sort
end

#source_exclude(exclude_list) ⇒ TopHitsAggregationBuilder

Parameters:

  • exclude_list (Array)

Returns:



58
59
60
61
62
# File 'lib/aggregations/buckets/top_hits_aggregation_builder.rb', line 58

def source_exclude exclude_list
  @_source ||= {}
  @_source[:exclude] = exclude_list if exclude_list.present?
  self
end

#source_exclude_exprArray

Returns:

  • (Array)


71
72
73
74
# File 'lib/aggregations/buckets/top_hits_aggregation_builder.rb', line 71

def source_exclude_expr
  return [] unless @_source.present?
  @_source[:exclude]
end

#source_include(include_list) ⇒ TopHitsAggregationBuilder

Parameters:

  • include_list (Array)

Returns:



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

def source_include include_list
  @_source ||= {}
  @_source[:include] = include_list if include_list.present?
  self
end

#source_include_exprArray

Returns:

  • (Array)


65
66
67
68
# File 'lib/aggregations/buckets/top_hits_aggregation_builder.rb', line 65

def source_include_expr
  return [] unless @_source.present?
  @_source[:include]
end