Class: ElasticsearchDslBuilder::DSL::Search::Aggregations::SumBucket

Inherits:
Aggregation
  • Object
show all
Defined in:
lib/elasticsearch_dsl_builder/dsl/search/aggregations/sum_bucket.rb

Instance Method Summary collapse

Methods inherited from Aggregation

#aggregation

Constructor Details

#initialize(buckets_path) ⇒ SumBucket

Returns a new instance of SumBucket.



6
7
8
9
10
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/sum_bucket.rb', line 6

def initialize(buckets_path)
  @type = :sum_bucket
  buckets_path(buckets_path)
  super()
end

Instance Method Details

#buckets_path(buckets_path) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/sum_bucket.rb', line 12

def buckets_path(buckets_path)
  raise ArgumentError, 'buckets_path must be a String' unless buckets_path.instance_of?(String)
  @buckets_path = buckets_path
  self
end

#format(format) ⇒ Object

Raises:

  • (ArgumentError)


24
25
26
27
28
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/sum_bucket.rb', line 24

def format(format)
  raise ArgumentError, 'format must be a String' unless format.instance_of?(String)
  @format = format
  self
end

#gap_policy(gap_policy) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/sum_bucket.rb', line 18

def gap_policy(gap_policy)
  raise ArgumentError, 'gap_policy must be a String' unless gap_policy.instance_of?(String)
  @gap_policy = gap_policy
  self
end

#to_hashObject



30
31
32
33
34
35
36
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/sum_bucket.rb', line 30

def to_hash
  @aggregation = { buckets_path: @buckets_path }
  @aggregation.update(field: @field) if @field
  @aggregation.update(gap_policy: @gap_policy) if @gap_policy
  @aggregation.update(format: @format) if @format
  super
end