Class: Blocktrain::Aggregations::CarWeightAggregation

Inherits:
Blocktrain::Aggregation show all
Defined in:
lib/blocktrain/aggregations/car_weight_aggregation.rb

Instance Method Summary collapse

Methods inherited from Blocktrain::Aggregation

#address_query, #body, #initialize, #parse_datetime, #query, #results

Constructor Details

This class inherits a constructor from Blocktrain::Aggregation

Instance Method Details

#aggsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/blocktrain/aggregations/car_weight_aggregation.rb', line 5

def aggs
  {
    weight_chart: {
      date_histogram: {
        field: 'timeStamp',
        interval: @interval,
        pre_zone: '+01:00',
        pre_zone_adjust_large_interval: true,
        min_doc_count: 1,
        extended_bounds: {
          min: @from,
          max: @to
        }
      },
      aggregations: car_weight_aggs
    }
  }
end

#car_weight_aggsObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/blocktrain/aggregations/car_weight_aggregation.rb', line 24

def car_weight_aggs
  {
    weight: {
      terms: { field: 'memoryAddress' },
      aggregations: {
        avg_weight: {
          avg: {
            field: 'value'
          }
        },
        max_weight: {
          max: {
            field: 'value'
          }
        },
        min_weight: {
          min: {
            field: 'value'
          }
        }
      }
    }
  }
end