Class: Solr::Query::Request::GeoFilter

Inherits:
Object
  • Object
show all
Includes:
Support::SchemaHelper
Defined in:
lib/solr/query/request/geo_filter.rb

Constant Summary collapse

SPATIAL_RADIUS =

roughly 100mi

161

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Support::SchemaHelper

#solarize_field

Constructor Details

#initialize(field:, latitude:, longitude:, spatial_radius: SPATIAL_RADIUS) ⇒ GeoFilter

Returns a new instance of GeoFilter.



11
12
13
14
15
16
17
# File 'lib/solr/query/request/geo_filter.rb', line 11

def initialize(field:, latitude:, longitude:, spatial_radius: SPATIAL_RADIUS)
  @field = field
  @latitude = latitude
  @longitude = longitude
  @spatial_radius = spatial_radius
  freeze
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



9
10
11
# File 'lib/solr/query/request/geo_filter.rb', line 9

def field
  @field
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



9
10
11
# File 'lib/solr/query/request/geo_filter.rb', line 9

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



9
10
11
# File 'lib/solr/query/request/geo_filter.rb', line 9

def longitude
  @longitude
end

#spatial_radiusObject (readonly)

Returns the value of attribute spatial_radius.



9
10
11
# File 'lib/solr/query/request/geo_filter.rb', line 9

def spatial_radius
  @spatial_radius
end

Instance Method Details

#to_solr_sObject



19
20
21
22
# File 'lib/solr/query/request/geo_filter.rb', line 19

def to_solr_s
  solr_field = solarize_field(@field)
  "{!geofilt sfield=#{solr_field} pt=#{@latitude},#{@longitude} d=#{spatial_radius}}"
end