Class: Arelastic::Sorts::GeoDistance
- Inherits:
-
Sort
- Object
- Nodes::Node
- Sort
- Arelastic::Sorts::GeoDistance
- Defined in:
- lib/arelastic/sorts/geo_distance.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
Returns the value of attribute field.
-
#location ⇒ Object
Returns the value of attribute location.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #as_elastic ⇒ Object
-
#initialize(field, location, options = {}) ⇒ GeoDistance
constructor
GeoDistance.new(‘coordinates’, [-70, 40]).as_elastic => => {‘coordinates’ => [-70, 40]}.
Methods inherited from Nodes::Node
#==, #convert_to_elastic, #hash, #read_option!
Methods included from Arities::Binary
Methods included from Arities::Polyadic
Methods included from Arities::Unary
Constructor Details
#initialize(field, location, options = {}) ⇒ GeoDistance
GeoDistance.new(‘coordinates’, [-70, 40]).as_elastic
=> {'_geo_distance' => {'coordinates' => [-70, 40]}}
GeoDistance.new(‘coordinates’, [-70, 40], ‘distance_type’ => ‘plane’).as_elastic
=> {'_geo_distance' => {'coordinates' => [-70, 40], 'distance_type' => 'plane'}}
12 13 14 15 16 |
# File 'lib/arelastic/sorts/geo_distance.rb', line 12 def initialize(field, location, = {}) @field = field @location = location @options = end |
Instance Attribute Details
#field ⇒ Object
Returns the value of attribute field.
4 5 6 |
# File 'lib/arelastic/sorts/geo_distance.rb', line 4 def field @field end |
#location ⇒ Object
Returns the value of attribute location.
4 5 6 |
# File 'lib/arelastic/sorts/geo_distance.rb', line 4 def location @location end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/arelastic/sorts/geo_distance.rb', line 4 def @options end |
Instance Method Details
#as_elastic ⇒ Object
18 19 20 |
# File 'lib/arelastic/sorts/geo_distance.rb', line 18 def as_elastic {'_geo_distance' => {field => location}.update()} end |