Class: Geoblacklight::BboxFilterQuery

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

Instance Method Summary collapse

Constructor Details

#initialize(blacklight_config:) ⇒ BboxFilterQuery

Returns a new instance of BboxFilterQuery.



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

def initialize(blacklight_config:)
  @blacklight_config = blacklight_config
end

Instance Method Details

#boostObject



38
39
40
# File 'app/models/concerns/geoblacklight/bbox_filter_query.rb', line 38

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

#call(filter, solr_params) ⇒ Object



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

def call(filter, solr_params)
  @filter = filter
  [intersects_filter, relevancy_boost(solr_params)]
end

#envelope_boundsObject



34
35
36
# File 'app/models/concerns/geoblacklight/bbox_filter_query.rb', line 34

def envelope_bounds
  @filter.values.first.to_envelope
end

#intersects_filterObject



14
15
16
# File 'app/models/concerns/geoblacklight/bbox_filter_query.rb', line 14

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

#relevancy_boost(solr_params) ⇒ Object



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

def relevancy_boost(solr_params)
  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