Class: Sunspot::Query::Local
- Inherits:
-
Object
- Object
- Sunspot::Query::Local
- 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
-
#initialize(coordinates, options) ⇒ Local
constructor
:nodoc:.
- #to_params ⇒ Object
Constructor Details
#initialize(coordinates, options) ⇒ Local
:nodoc:
10 11 12 |
# File 'lib/sunspot/query/local.rb', line 10 def initialize(coordinates, ) @coordinates, @options = Util::Coordinates.new(coordinates), end |
Instance Method Details
#to_params ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sunspot/query/local.rb', line 14 def to_params local_params = [ [:radius, @options[:distance]], [:sort, @options[:sort]] ].map do |key,value| "#{key}=#{value}" if value end.compact.join(" ") #TODO Centralized local param builder query = "{!#{local_params}}#{@coordinates.lat},#{@coordinates.lng}" { :spatial => query } end |