Class: Blocktrain::Aggregation
- Defined in:
- lib/blocktrain/aggregation.rb
Direct Known Subclasses
Blocktrain::Aggregations::HistogramAggregation, Blocktrain::Aggregations::TermsAggregation
Instance Method Summary collapse
- #aggs ⇒ Object
- #body ⇒ Object
-
#initialize(options = {}) ⇒ Aggregation
constructor
A new instance of Aggregation.
- #results ⇒ Object
Methods inherited from Query
#address_query, #build_query, #filtered_filter, #filtered_query, #hits, #parse_datetime, #query
Constructor Details
#initialize(options = {}) ⇒ Aggregation
Returns a new instance of Aggregation.
3 4 5 6 |
# File 'lib/blocktrain/aggregation.rb', line 3 def initialize( = {}) @interval = .fetch(:interval, '10m') super end |
Instance Method Details
#aggs ⇒ Object
12 13 14 |
# File 'lib/blocktrain/aggregation.rb', line 12 def aggs raise RuntimeError.new("Aggregation cannot be used directly. Use a derived class instead like AverageAggregation.") end |
#body ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/blocktrain/aggregation.rb', line 16 def body { query: query, size: 0, aggregations: aggs, } end |
#results ⇒ Object
8 9 10 |
# File 'lib/blocktrain/aggregation.rb', line 8 def results result['aggregations'] end |