Module: Arclight::SearchBehavior

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/arclight/search_behavior.rb

Overview

Customized Search Behavior for Arclight

Instance Method Summary collapse

Instance Method Details

#add_facetting_to_solr(solr_params) ⇒ Object

Override Blacklight’s method so that some views don’t add Solr facets into the request.



20
21
22
23
24
25
26
# File 'app/models/concerns/arclight/search_behavior.rb', line 20

def add_facetting_to_solr(solr_params)
  if %w[collection_context online_contents].include? blacklight_params[:view]
    return solr_params
  end

  super(solr_params)
end

#add_grouping(solr_params) ⇒ Object

Adds grouping parameters for Solr if enabled



55
56
57
58
59
# File 'app/models/concerns/arclight/search_behavior.rb', line 55

def add_grouping(solr_params)
  solr_params.merge!(Arclight::Engine.config.catalog_controller_group_query_params) if blacklight_params[:group] == 'true'

  solr_params
end

#add_hierarchy_max_rows(solr_params) ⇒ Object

For the collection_context views, set a higher (unlimited) maximum document return



30
31
32
33
34
35
# File 'app/models/concerns/arclight/search_behavior.rb', line 30

def add_hierarchy_max_rows(solr_params)
  if %w[collection_context].include? blacklight_params[:view]
    solr_params[:rows] = 999_999_999
  end
  solr_params
end

#add_hierarchy_sort(solr_params) ⇒ Object

For the asynch views, set the sort order to preserve the order of components



39
40
41
42
# File 'app/models/concerns/arclight/search_behavior.rb', line 39

def add_hierarchy_sort(solr_params)
  solr_params[:sort] = 'sort_ii asc' if %w[online_contents collection_context].include? blacklight_params[:view]
  solr_params
end

#add_highlighting(solr_params) ⇒ Object

Add highlighting



46
47
48
49
50
51
# File 'app/models/concerns/arclight/search_behavior.rb', line 46

def add_highlighting(solr_params)
  solr_params['hl'] = true
  solr_params['hl.fl'] = 'text'
  solr_params['hl.snippets'] = 3
  solr_params
end