Class: Sunspot::Query::Geo

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

Constant Summary

MAX_PRECISION =
12
DEFAULT_PRECISION =
7
DEFAULT_PRECISION_FACTOR =
16.0

Instance Method Summary (collapse)

Constructor Details

- (Geo) initialize(field, lat, lng, options)

A new instance of Geo



14
15
16
17
# File 'sunspot/lib/sunspot/query/geo.rb', line 14

def initialize(field, lat, lng, options)
  @field, @options = field, options
  @geohash = GeoHash.encode(lat.to_f, lng.to_f, MAX_PRECISION)
end

Instance Method Details

- (Object) to_params



19
20
21
# File 'sunspot/lib/sunspot/query/geo.rb', line 19

def to_params
  { :q => to_boolean_query }
end

- (Object) to_subquery



23
24
25
# File 'sunspot/lib/sunspot/query/geo.rb', line 23

def to_subquery
  "(#{to_boolean_query})"
end