Module: BlacklightHeatmaps::SolrFacetHeatmapBehavior

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/blacklight_heatmaps/solr_facet_heatmap_behavior.rb

Overview

Extends itself into a consuming application’s SearchBuilder and adds relevancy, spatial search, and heatmap functionality.

Instance Method Summary collapse

Instance Method Details

#add_solr_facet_heatmap(solr_parameters = {}) ⇒ Object

Add Solr spatial heatmap parameters to Solr request



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/concerns/blacklight_heatmaps/solr_facet_heatmap_behavior.rb', line 14

def add_solr_facet_heatmap(solr_parameters = {})
  if blacklight_params[:bbox]
    solr_parameters['facet.heatmap'] = geometry_field
    solr_parameters['facet.heatmap.geom'] = bbox_as_range
    solr_parameters['facet.heatmap.distErrPct'] = dist_err_pct
    solr_parameters[:bq] ||= []
    solr_parameters[:bq] << "#{geometry_field}:\"IsWithin(#{bbox_as_envelope})\""
    solr_parameters[:fq] ||= []
    solr_parameters[:fq] << "#{geometry_field}:\"Intersects(#{bbox_as_envelope})\""
  end
  solr_parameters
end

#bboxObject

‘bbox` parameter is in format “west,south,east,north”

Returns:

  • Array



38
39
40
# File 'app/models/concerns/blacklight_heatmaps/solr_facet_heatmap_behavior.rb', line 38

def bbox
  blacklight_params[:bbox].split(',')
end

#bbox_as_envelopeObject

Returns:

  • String



46
47
48
# File 'app/models/concerns/blacklight_heatmaps/solr_facet_heatmap_behavior.rb', line 46

def bbox_as_envelope
  BlacklightHeatmaps::BoundingBox.new(*bbox).to_envelope
end

#bbox_as_rangeObject

Returned in rectangle-range syntax [“-180 -90” TO “180 90”] cwiki.apache.org/confluence/display/solr/Spatial+Search

Returns:

  • String



54
55
56
# File 'app/models/concerns/blacklight_heatmaps/solr_facet_heatmap_behavior.rb', line 54

def bbox_as_range
  "[\"#{bbox[0]} #{bbox[1]}\" TO \"#{bbox[2]} #{bbox[3]}\"]"
end

#dist_err_pctObject



27
28
29
# File 'app/models/concerns/blacklight_heatmaps/solr_facet_heatmap_behavior.rb', line 27

def dist_err_pct
  blacklight_config.heatmap_distErrPct || 0.15
end

#geometry_fieldObject



31
32
33
# File 'app/models/concerns/blacklight_heatmaps/solr_facet_heatmap_behavior.rb', line 31

def geometry_field
  blacklight_config.geometry_field
end