Module: Elastic::Dsl::MetricBuilder
- Included in:
- ResultComposer, Query
- Defined in:
- lib/elastic/dsl/metric_builder.rb
Instance Method Summary collapse
- #average(_field, _options = {}) ⇒ Object
- #closing(_field, _options = {}) ⇒ Object
- #maximum(_field, _options = {}) ⇒ Object
- #minimum(_field, _options = {}) ⇒ Object
- #opening(_field, _options = {}) ⇒ Object
- #stats(_field, _options = {}) ⇒ Object
- #sum(_field, _options = {}) ⇒ Object
Instance Method Details
#average(_field, _options = {}) ⇒ Object
3 4 5 |
# File 'lib/elastic/dsl/metric_builder.rb', line 3 def average(_field, = {}) aggregate_metric(Elastic::Nodes::Agg::Average, _field, , 'avg_%s') end |
#closing(_field, _options = {}) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/elastic/dsl/metric_builder.rb', line 32 def closing(_field, = {}) by = .delete :by raise ArgumentError, 'must provide a sorting column' if by.nil? aggregate_metric(Elastic::Nodes::Agg::Top, _field, , 'close_%s') do |node| node.add_sort(by, order: :desc) end end |
#maximum(_field, _options = {}) ⇒ Object
15 16 17 |
# File 'lib/elastic/dsl/metric_builder.rb', line 15 def maximum(_field, = {}) aggregate_metric(Elastic::Nodes::Agg::Maximum, _field, , 'max_%s') end |
#minimum(_field, _options = {}) ⇒ Object
11 12 13 |
# File 'lib/elastic/dsl/metric_builder.rb', line 11 def minimum(_field, = {}) aggregate_metric(Elastic::Nodes::Agg::Minimum, _field, , 'min_%s') end |
#opening(_field, _options = {}) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/elastic/dsl/metric_builder.rb', line 23 def opening(_field, = {}) by = .delete :by raise ArgumentError, 'must provide a sorting column' if by.nil? aggregate_metric(Elastic::Nodes::Agg::Top, _field, , 'open_%s') do |node| node.add_sort(by, order: :asc) end end |