Class: Arelastic::Queries::GeoDistance

Inherits:
Query show all
Defined in:
lib/arelastic/queries/geo_distance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Query

#negate, #nested

Methods inherited from Nodes::Node

#==, #convert_to_elastic, #read_option!

Methods included from Arities::Binary

#binary

Methods included from Arities::Polyadic

#polyadic

Methods included from Arities::Unary

#unary

Constructor Details

#initialize(field, location, distance, options = {}) ⇒ GeoDistance

Returns a new instance of GeoDistance.



5
6
7
8
9
10
# File 'lib/arelastic/queries/geo_distance.rb', line 5

def initialize(field, location, distance, options = {})
  @field = field
  @location = location
  @distance = distance
  @options = options
end

Instance Attribute Details

#distanceObject

Returns the value of attribute distance.



4
5
6
# File 'lib/arelastic/queries/geo_distance.rb', line 4

def distance
  @distance
end

#fieldObject

Returns the value of attribute field.



4
5
6
# File 'lib/arelastic/queries/geo_distance.rb', line 4

def field
  @field
end

#locationObject

Returns the value of attribute location.



4
5
6
# File 'lib/arelastic/queries/geo_distance.rb', line 4

def location
  @location
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/arelastic/queries/geo_distance.rb', line 4

def options
  @options
end

Instance Method Details

#as_elasticObject



12
13
14
15
16
# File 'lib/arelastic/queries/geo_distance.rb', line 12

def as_elastic
  params = { field => location, "distance" => distance }.update(options)

  { "geo_distance" => params }
end