Class: Geoblacklight::BboxFilterQuery

Inherits:
Object
  • Object
show all
Defined in:
app/models/concerns/geoblacklight/bbox_filter_query.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filter, solr_params) ⇒ BboxFilterQuery

Returns a new instance of BboxFilterQuery.



11
12
13
14
# File 'app/models/concerns/geoblacklight/bbox_filter_query.rb', line 11

def initialize(filter, solr_params)
  @filter = filter
  @solr_params = solr_params
end

Class Method Details

.call(_search_builder, filter, solr_params) ⇒ Object



5
6
7
8
9
# File 'app/models/concerns/geoblacklight/bbox_filter_query.rb', line 5

def self.call(_search_builder, filter, solr_params)
  bbox_filter_query = Geoblacklight::BboxFilterQuery.new(filter, solr_params)

  [bbox_filter_query.intersects_filter, bbox_filter_query.relevancy_boost]
end

Instance Method Details

#boostObject



40
41
42
# File 'app/models/concerns/geoblacklight/bbox_filter_query.rb', line 40

def boost
  "^#{field_config.within_boost || "10"}"
end

#envelope_boundsObject



36
37
38
# File 'app/models/concerns/geoblacklight/bbox_filter_query.rb', line 36

def envelope_bounds
  @filter.values.first.to_envelope
end

#intersects_filterObject



16
17
18
# File 'app/models/concerns/geoblacklight/bbox_filter_query.rb', line 16

def intersects_filter
  "#{@filter.key}:\"Intersects(#{envelope_bounds})\""
end

#relevancy_boostObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/concerns/geoblacklight/bbox_filter_query.rb', line 20

def relevancy_boost
  boosted_params = @solr_params.slice(:bq, :bf)

  boosted_params[:bq] ||= []
  boosted_params[:bq] << "#{@filter.key}:\"IsWithin(#{envelope_bounds})\"#{boost}"

  if field_config.overlap_boost
    boosted_params[:bf] ||= []
    boosted_params[:overlap] =
      "{!field uf=* defType=lucene f=#{field_config.overlap_field} score=overlapRatio}Intersects(#{envelope_bounds})"
    boosted_params[:bf] << "$overlap^#{field_config.overlap_boost}"
  end

  boosted_params
end