Class: Blocktrain::Aggregation

Inherits:
Query
  • Object
show all
Defined in:
lib/blocktrain/aggregation.rb

Instance Method Summary collapse

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(options = {})
  @interval = options.fetch(:interval, '10m')
  super
end

Instance Method Details

#aggsObject

Raises:

  • (RuntimeError)


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

#bodyObject



16
17
18
19
20
21
22
# File 'lib/blocktrain/aggregation.rb', line 16

def body
  {
    query: query,
    size: 0,
    aggregations: aggs,
  }
end

#resultsObject



8
9
10
# File 'lib/blocktrain/aggregation.rb', line 8

def results
  result['aggregations']
end