Class: ElasticsearchDslBuilder::DSL::Search::Aggregations::GeohashGrid

Inherits:
Aggregation
  • Object
show all
Defined in:
lib/elasticsearch_dsl_builder/dsl/search/aggregations/geohash_grid.rb

Instance Method Summary collapse

Methods inherited from Aggregation

#aggregation

Constructor Details

#initialize(field) ⇒ GeohashGrid

Returns a new instance of GeohashGrid.



6
7
8
9
10
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/geohash_grid.rb', line 6

def initialize(field)
  @type = :geohash_grid
  field(field)
  super()
end

Instance Method Details

#field(field) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/geohash_grid.rb', line 12

def field(field)
  raise ArgumentError, 'field must be a String' unless field.instance_of?(String)
  @field = field
  self
end

#precision(precision) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/geohash_grid.rb', line 18

def precision(precision)
  raise ArgumentError, 'precision must be a Numeric' unless precision.is_a?(Numeric)
  @precision = precision
  self
end

#shard_size(shard_size) ⇒ Object

Raises:

  • (ArgumentError)


30
31
32
33
34
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/geohash_grid.rb', line 30

def shard_size(shard_size)
  raise ArgumentError, 'shard_size must be a Numeric' unless shard_size.is_a?(Numeric)
  @shard_size = shard_size
  self
end

#size(size) ⇒ Object

Raises:

  • (ArgumentError)


24
25
26
27
28
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/geohash_grid.rb', line 24

def size(size)
  raise ArgumentError, 'size must be a Numeric' unless size.is_a?(Numeric)
  @size = size
  self
end

#to_hashObject



36
37
38
39
40
41
42
# File 'lib/elasticsearch_dsl_builder/dsl/search/aggregations/geohash_grid.rb', line 36

def to_hash
  @aggregation = { field: @field }
  @aggregation.update(precision: @precision) if @precision
  @aggregation.update(size: @size) if @size
  @aggregation.update(shard_size: @shard_size) if @shard_size
  super
end