Class: Elasticband::Query::ScoreFunction::GeoLocation

Inherits:
Gauss show all
Defined in:
lib/elasticband/query/score_function/geo_location.rb

Instance Attribute Summary

Attributes inherited from Gauss

#options

Instance Method Summary collapse

Methods inherited from Gauss

#to_h

Methods inherited from Elasticband::Query::ScoreFunction

#to_h

Constructor Details

#initialize(options) ⇒ GeoLocation

Returns a new instance of GeoLocation.



5
6
7
8
9
10
11
12
13
14
# File 'lib/elasticband/query/score_function/geo_location.rb', line 5

def initialize(options)
  return unless options.present?

  origin = { lat: options[:latitude], lon: options[:longitude] }
  distance = options[:distance]
  location = { origin: origin, offset: distance[:same_score], scale: distance[:half_score] }
  field = options[:on] || :location

  super(field => location)
end