Class: Elasticated::GeohashGridAggregation

Inherits:
Aggregation
  • Object
show all
Defined in:
lib/elasticated/aggregations/geohash_grid_aggregation.rb

Instance Attribute Summary

Attributes inherited from Aggregation

#alias_name, #extra_params, #field

Instance Method Summary collapse

Methods inherited from Aggregation

#initialize, #name, #original_name

Methods included from Mixins::Inspectionable

#inspect, #text_for_inspect

Methods included from Mixins::BlockEvaluation

#evaluate

Methods included from Mixins::Clonable

#==, #clone

Constructor Details

This class inherits a constructor from Elasticated::Aggregation

Instance Method Details

#buildObject

TODO: this is exactly the same as in SingleValueAggregation



9
10
11
12
13
# File 'lib/elasticated/aggregations/geohash_grid_aggregation.rb', line 9

def build
  operation_info = { field: field }
  operation_info.merge! extra_params
  { operation => operation_info }
end

#default_nameObject



4
5
6
# File 'lib/elasticated/aggregations/geohash_grid_aggregation.rb', line 4

def default_name
  "geohash_grid_by_#{field}"
end

#parse(response) ⇒ Object



15
16
17
18
19
# File 'lib/elasticated/aggregations/geohash_grid_aggregation.rb', line 15

def parse(response)
  response['buckets'].each_with_object({}) do |bucket, hash|
    hash[bucket['key']] = bucket['doc_count']
  end
end