Class: Sunspot::Query::Geofilt

Inherits:
Object
  • Object
show all
Includes:
Filter
Defined in:
lib/sunspot/query/geofilt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Filter

#tag, #to_filter_query

Constructor Details

#initialize(field, lat, lon, radius, options = {}) ⇒ Geofilt

Returns a new instance of Geofilt.



7
8
9
# File 'lib/sunspot/query/geofilt.rb', line 7

def initialize(field, lat, lon, radius, options = {})
  @field, @lat, @lon, @radius, @options = field, lat, lon, radius, options
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



5
6
7
# File 'lib/sunspot/query/geofilt.rb', line 5

def field
  @field
end

Instance Method Details

#to_boolean_phraseObject



11
12
13
14
# File 'lib/sunspot/query/geofilt.rb', line 11

def to_boolean_phrase
  func = @options[:bbox] ? "bbox" : "geofilt"
  "{!#{func} sfield=#{@field.indexed_name} pt=#{@lat},#{@lon} d=#{@radius}}"
end

#to_paramsObject



16
17
18
# File 'lib/sunspot/query/geofilt.rb', line 16

def to_params
  {:fq => to_filter_query}
end