Module: Geoblacklight::SpatialSearchBehavior
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/geoblacklight/spatial_search_behavior.rb
Instance Method Summary collapse
-
#add_spatial_params(solr_params) ⇒ Blacklight::Solr::Request
Adds spatial parameters to a Solr query if :bbox is present.
-
#boost ⇒ String
Allow bq boost to be configured, default 10 for backwards compatibility.
-
#bounding_box ⇒ Geoblacklight::BoundingBox
Returns a Geoblacklight::BoundingBox built from the blacklight_params.
- #envelope_bounds ⇒ String
-
#hide_suppressed_records(solr_params) ⇒ Blacklight::Solr::Request
Hide suppressed records in search.
Instance Method Details
#add_spatial_params(solr_params) ⇒ Blacklight::Solr::Request
Adds spatial parameters to a Solr query if :bbox is present. :bbox should be passed in using Solr lat-lon rectangle format e.g. “minX minY maxX maxY”
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/concerns/geoblacklight/spatial_search_behavior.rb', line 15 def add_spatial_params(solr_params) if blacklight_params[:bbox] solr_params[:bq] ||= [] solr_params[:bq] << "#{Settings.FIELDS.GEOMETRY}:\"IsWithin(#{envelope_bounds})\"#{boost}" solr_params[:fq] ||= [] solr_params[:fq] << "#{Settings.FIELDS.GEOMETRY}:\"Intersects(#{envelope_bounds})\"" if Settings.OVERLAP_RATIO_BOOST solr_params[:overlap] = "{!field uf=* defType=lucene f=solr_bboxtype score=overlapRatio}Intersects(#{envelope_bounds})" solr_params[:bf] = "$overlap^#{Settings.OVERLAP_RATIO_BOOST}" end end solr_params rescue Geoblacklight::Exceptions::WrongBoundingBoxFormat # TODO: Potentially delete bbox params here so that its not rendered as search param solr_params end |
#boost ⇒ String
Allow bq boost to be configured, default 10 for backwards compatibility
42 43 44 |
# File 'app/models/concerns/geoblacklight/spatial_search_behavior.rb', line 42 def boost "^#{Settings.BBOX_WITHIN_BOOST || '10'}" end |
#bounding_box ⇒ Geoblacklight::BoundingBox
Returns a Geoblacklight::BoundingBox built from the blacklight_params
49 50 51 |
# File 'app/models/concerns/geoblacklight/spatial_search_behavior.rb', line 49 def bounding_box Geoblacklight::BoundingBox.from_rectangle(blacklight_params[:bbox]) end |
#envelope_bounds ⇒ String
36 37 38 |
# File 'app/models/concerns/geoblacklight/spatial_search_behavior.rb', line 36 def envelope_bounds bounding_box.to_envelope end |
#hide_suppressed_records(solr_params) ⇒ Blacklight::Solr::Request
Hide suppressed records in search
57 58 59 60 61 62 |
# File 'app/models/concerns/geoblacklight/spatial_search_behavior.rb', line 57 def hide_suppressed_records(solr_params) # Show child records if searching for a specific source parent return unless blacklight_params.fetch(:f, {})[Settings.FIELDS.SOURCE.to_sym].nil? solr_params[:fq] ||= [] solr_params[:fq] << '-suppressed_b: true' end |