Class: ElasticsearchDslBuilder::DSL::Search::Aggregations::Stats
- Inherits:
-
Aggregation
- Object
- Aggregation
- ElasticsearchDslBuilder::DSL::Search::Aggregations::Stats
- Defined in:
- lib/elasticsearch_dsl_builder/dsl/search/aggregations/stats.rb
Instance Method Summary collapse
- #field(field) ⇒ Object
-
#initialize ⇒ Stats
constructor
A new instance of Stats.
- #missing(missing) ⇒ Object
- #script(script) ⇒ Object
- #to_hash ⇒ Object
Methods inherited from Aggregation
Constructor Details
#initialize ⇒ Stats
Returns a new instance of Stats.
6 7 8 9 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/stats.rb', line 6 def initialize @type = :stats super() end |
Instance Method Details
#field(field) ⇒ Object
11 12 13 14 15 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/stats.rb', line 11 def field(field) raise ArgumentError, 'field must be a String' unless field.instance_of?(String) @field = field self end |
#missing(missing) ⇒ Object
23 24 25 26 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/stats.rb', line 23 def missing(missing) @missing = missing self end |
#script(script) ⇒ Object
17 18 19 20 21 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/stats.rb', line 17 def script(script) raise ArgumentError, 'script must be a Script' unless script.instance_of?(Script) @script = script self end |
#to_hash ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/stats.rb', line 28 def to_hash raise ArgumentError, 'must have set at least one of [field, script]' if @field.nil? && @script.nil? @aggregation = {} @aggregation.update(field: @field) if @field @aggregation.update(script: @script.to_hash) if @script @aggregation.update(missing: @missing) if @missing super end |