Class: Sunspot::Query::Sort::GeodistSort

Inherits:
FieldSort show all
Defined in:
lib/sunspot/query/sort.rb

Overview

A GeodistSort sorts by distance from a given point.

Instance Method Summary collapse

Constructor Details

#initialize(field, lat, lon, direction) ⇒ GeodistSort

Returns a new instance of GeodistSort.



102
103
104
105
# File 'lib/sunspot/query/sort.rb', line 102

def initialize(field, lat, lon, direction)
  @lat, @lon = lat, lon
  super(field, direction)
end

Instance Method Details

#to_paramObject



107
108
109
# File 'lib/sunspot/query/sort.rb', line 107

def to_param
  "geodist(#{@field.indexed_name.to_sym},#{@lat},#{@lon}) #{direction_for_solr}"
end