Class: Sunspot::Query::Local

Inherits:
Object
  • Object
show all
Defined in:
lib/sunspot/query/local.rb

Overview

This query component generates parameters for LocalSolr geo-radial searches. The LocalSolr API is fairly rigid, so the Local component doesn’t have any options - it just takes coordinates and a radius, and generates the appropriate parameters.

Instance Method Summary collapse

Constructor Details

#initialize(coordinates, radius) ⇒ Local

:nodoc:



10
11
12
13
14
15
# File 'lib/sunspot/query/local.rb', line 10

def initialize(coordinates, radius)
  if radius < 1
    raise ArgumentError, "LocalSolr does not seem to support a radius of less than 1 mile."
  end
  @coordinates, @radius = Util::Coordinates.new(coordinates), radius
end

Instance Method Details

#to_paramsObject



17
18
19
20
21
22
23
24
# File 'lib/sunspot/query/local.rb', line 17

def to_params
  {
    :qt => 'geo',
    :lat => @coordinates.lat,
    :long => @coordinates.lng,
    :radius => @radius
  }
end