class Sunspot::Type::LocationType

The Location type encodes geographical coordinates as a GeoHash. The data for this type must respond to the `lat` and `lng` methods; you can use Sunspot::Util::Coordinates as a wrapper if your source data does not follow this API.

Location fields are most usefully searched using the Sunspot::DSL::RestrictionWithType#near method; see that method for more information on geographical search.

Example

Sunspot.setup(Post) do
  location :coordinates do
    Sunspot::Util::Coordinates.new(coordinates[0], coordinates[1])
  end
end

Public Instance Methods

indexed_name(name) click to toggle source
# File lib/sunspot/type.rb, line 348
def indexed_name(name)
  "#{name}_s"
end
to_indexed(value) click to toggle source
# File lib/sunspot/type.rb, line 352
def to_indexed(value)
  GeoHash.encode(value.lat.to_f, value.lng.to_f, 12)
end