Class: JayAPI::Elasticsearch::QueryBuilder::Aggregations::ScriptedMetric

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

Overview

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

Instance Attribute Summary collapse

Attributes inherited from Aggregation

#name

Instance Method Summary collapse

Constructor Details

#initialize(name, map_script:, combine_script:, reduce_script:, init_script: nil) ⇒ ScriptedMetric



30
31
32
33
34
35
36
37
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/scripted_metric.rb', line 30

def initialize(name, map_script:, combine_script:, reduce_script:, init_script: nil)
  super(name)

  @init_script = init_script
  @map_script = map_script
  @combine_script = combine_script
  @reduce_script = reduce_script
end

Instance Attribute Details

#combine_scriptObject (readonly)

Returns the value of attribute combine_script.



13
14
15
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/scripted_metric.rb', line 13

def combine_script
  @combine_script
end

#init_scriptObject (readonly)

Returns the value of attribute init_script.



13
14
15
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/scripted_metric.rb', line 13

def init_script
  @init_script
end

#map_scriptObject (readonly)

Returns the value of attribute map_script.



13
14
15
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/scripted_metric.rb', line 13

def map_script
  @map_script
end

#reduce_scriptObject (readonly)

Returns the value of attribute reduce_script.



13
14
15
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/scripted_metric.rb', line 13

def reduce_script
  @reduce_script
end

Instance Method Details

#aggsObject

Raises:



42
43
44
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/scripted_metric.rb', line 42

def aggs
  no_nested_aggregations('Scripted Metric')
end

#cloneself



47
48
49
50
51
52
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/scripted_metric.rb', line 47

def clone
  self.class.new(
    name, map_script: map_script, combine_script: combine_script,
          reduce_script: reduce_script, init_script: init_script
  )
end

#to_hHash



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/scripted_metric.rb', line 56

def to_h
  super do
    {
      scripted_metric: {
        init_script: init_script,
        map_script: map_script,
        combine_script: combine_script,
        reduce_script: reduce_script
      }.compact
    }
  end
end