Created
June 21, 2011 16:25
-
-
Save jrochkind/1038232 to your computer and use it in GitHub Desktop.
my (rails2) blacklight_config.rb as of now
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You can configure Blacklight from here. | |
# | |
# Blacklight.configure(:environment) do |config| end | |
# | |
# :shared (or leave it blank) is used by all environments. | |
# You can override a shared key by using that key in a particular | |
# environment's configuration. | |
# | |
# If you have no configuration beyond :shared for an environment, you | |
# do not need to call configure() for that envirnoment. | |
# | |
# For specific environments: | |
# | |
# Blacklight.configure(:test) {} | |
# Blacklight.configure(:development) {} | |
# Blacklight.configure(:production) {} | |
# | |
Blacklight.configure(:shared) do |config| | |
# Tell ruby marc to use best available installed parser, hopefully | |
# nokogiri, and output into log what we're using. | |
MARC::XMLReader.best_available! | |
Rails.logger.info("\nMARC::XMLReader using parser: \"#{MARC::XMLReader.parser}\"") | |
Rails.logger.flush | |
# setup and register the marc extension | |
SolrDocument.extension_parameters[:marc_source_field] = :marc_display | |
SolrDocument.extension_parameters[:marc_format_type] = :marc21 | |
SolrDocument.use_extension( Blacklight::Solr::Document::Marc) do |document| | |
document.key?( :marc_display ) | |
end | |
# Setup and register extension to provide better Marc to OpenURL mapping, | |
# from the MarcDisplay plugin | |
SolrDocument.extension_parameters[:rfr_id] = "info:sid:library.jhu.edu/blacklight" | |
if Rails.env == "production" | |
SolrDocument.extension_parameters[:self_uri_prefix] = "https://catalyst.library.jhu.edu/catalog/" | |
else | |
SolrDocument.extension_parameters[:self_uri_prefix] = "https://blacklight.mse.jhu.edu/demo/catalog/" | |
end | |
SolrDocument.use_extension(MarcDisplay::Blacklight::MarcToOpenUrlExtension) do |document| | |
document.respond_to?(:to_marc) | |
end | |
# dlf-expanded format passthrough | |
SolrDocument.extension_parameters[:ils_di_base] = HipConfig.ws_base_not_secure + "/holdings" | |
SolrDocument.use_extension( DlfExpandedPassthrough::DocumentExtension ) do |document| | |
document["id"] =~ /^bib_/ | |
end | |
# and add #to_holdings method too, based on dlf-expanded. | |
SolrDocument.use_extension( DlfExpandedPassthrough::ToHoldingsExtension) do |document| | |
document.respond_to?(:to_dlf_expanded) | |
end | |
# Add in bulk-loading of DLF responses behavior | |
CatalogController.class_eval do | |
include DlfExpandedPassthrough::BulkLoad | |
end | |
# single valued. See Blacklight::Solr::Document::ExtendableClassMethods#field_semantics | |
# and Blacklight::Solr::Document#to_semantic_value_hash | |
if (SolrDocument.respond_to?(:field_semantics)) | |
SolrDocument.field_semantics.merge!( | |
:title => "title_display", | |
:author => "author_display", | |
:publisher => "published_display", | |
:language => "language_facet" | |
) | |
end | |
############################## | |
config[:default_solr_params] = { | |
:qt => "search", | |
:per_page => 10, | |
:"facet.limit" => 9, | |
:"f.format.facet.limit" => -1, | |
:"facet.field" => [ | |
"format", | |
"location_facet", | |
"author_facet", | |
"language_facet", | |
"series_facet", | |
"discipline_facet", | |
"subject_topic_facet", | |
"subject_geo_facet", | |
"subject_era_facet", | |
"instrumentation_facet" | |
] | |
} | |
# solr field values given special treatment in the show (single result) view | |
config[:show] = { | |
:html_title => "title_display", | |
:heading => "title_display", | |
:display_type => "format" | |
} | |
# solr fld values given special treatment in the index (search results) view | |
config[:index] = { | |
:show_link => "title_display", | |
:record_display_type => "format" | |
} | |
# solr fields that will be treated as facets by the blacklight application | |
# The ordering of the field names is the order of the display | |
config[:facet] = { | |
:field_names => [ | |
"format", | |
"location_facet", | |
"pub_date_sort", | |
"author_facet", | |
"language_facet", | |
"subject_topic_facet", | |
"subject_geo_facet", | |
"subject_era_facet", | |
"series_facet", | |
"discipline_facet", | |
"instrumentation_facet" | |
], | |
:labels => { | |
"format" => "Format", | |
"location_facet" => "Library Location", | |
"pub_date_sort" => "Publication Year", | |
"author_facet" => "Author", | |
"subject_facet" => "Subject", | |
"language_facet" => "Language", | |
"series_facet" => "Series", | |
"discipline_facet" => "Discipline", | |
"subject_topic_facet" => "Topic", | |
"subject_era_facet" => "Topic (Era)", | |
"subject_geo_facet" => "Topic (Region)", | |
"instrumentation_facet" => "Musical Instrumentation", | |
}, | |
# Setting a limit will trigger Blacklight's 'more' facet values link. | |
# If left unset, then all facet values returned by solr will be displayed. | |
# nil key can be used for a general limit applying to all facets. | |
:limits => { | |
"format" => true, | |
"location_facet" => true, | |
"author_facet" => true, | |
"subject_facet" => true, | |
"language_facet" => true, | |
"series_facet" => true, | |
"discipline_facet" => true, | |
"subject_topic_facet" => true, | |
"subject_era_facet" => true, | |
"subject_geo_facet" => true, | |
"instrumentation_facet" => true | |
}, | |
:range => { | |
"pub_date_sort" => true | |
} | |
} | |
# solr fields to be displayed in the index (search results) view | |
# The ordering of the field names is the order of the display | |
config[:index_fields] = { | |
:field_names => [ | |
"title_display", | |
"title_vern_display", | |
"author_display", | |
"author_vern_display", | |
"format", | |
"language_facet", | |
"published_display", | |
"published_vern_display", | |
"lc_callnum_display" | |
], | |
:labels => { | |
"title_display" => "Title:", | |
"title_vern_display" => "Title:", | |
"author_display" => "Author:", | |
"author_vern_display" => "Author:", | |
"format" => "Format:", | |
"language_facet" => "Language:", | |
"published_display" => "Published:", | |
"published_vern_display" => "Published:", | |
"lc_callnum_display" => "Call number:" | |
} | |
} | |
# solr fields to be displayed in the show (single result) view | |
# The ordering of the field names is the order of the display | |
config[:show_fields] = { | |
:field_names => [ | |
"title_display", | |
"title_vern_display", | |
"subtitle_display", | |
"subtitle_vern_display", | |
"author_display", | |
"author_vern_display", | |
"format", | |
"url_fulltext_display", | |
"url_suppl_display", | |
"material_type_display", | |
"language_facet", | |
"published_display", | |
"published_vern_display", | |
"lc_callnum_display", | |
"isbn_t" | |
], | |
:labels => { | |
"title_display" => "Title:", | |
"title_vern_display" => "Title:", | |
"subtitle_display" => "Subtitle:", | |
"subtitle_vern_display" => "Subtitle:", | |
"author_display" => "Author:", | |
"author_vern_display" => "Author:", | |
"format" => "Format:", | |
"url_fulltext_display" => "URL:", | |
"url_suppl_display" => "More Information:", | |
"material_type_display" => "Physical description:", | |
"language_facet" => "Language:", | |
"published_display" => "Published:", | |
"published_vern_display" => "Published:", | |
"lc_callnum_display" => "Call number:", | |
"isbn_t" => "ISBN:" | |
} | |
} | |
# FIXME: is this now redundant with above? | |
# type of raw data in index. Currently marcxml and marc21 are supported. | |
config[:raw_storage_type] = "marc21" | |
# name of solr field containing raw data | |
config[:raw_storage_field] = "marc_display" | |
# These are over-rides sent to Solr when in :unstemmed_search mode | |
# They need to be kind of carefully calibrated with the settings in Solr | |
# and Blacklight for individual search types, sorry it's a bit fragile. | |
config[:unstemmed_overrides] = { | |
"title_qf" => [ | |
"title1_unstem^80", | |
"title2_unstem^60", | |
"title3_unstem^30", | |
"title_series_unstem^25" | |
], | |
"subject_qf" => "subject_unstem^40", | |
"series_qf" => "title_series_unstem^10", | |
# this 'qf' will be used for default 'all fields' search | |
# when in unstemmed mode, over-riding the qf defaults set | |
# in solrconfig.xml, which include some stemmed fields. | |
"qf" => [ | |
'title1_unstem^80', | |
'title2_unstem^60', | |
'title3_unstem^20', | |
'author_unstem^90', | |
'author2_unstem^40', | |
'subject_unstem^20', | |
'title_series_unstem^10', | |
'isbn_t', | |
'issn', | |
'issn_related', | |
'local_call_number_t', | |
'oclcnum_t', | |
'lccn', | |
'text_unstem^2', | |
'text_extra_boost_unstem^6' | |
] | |
} | |
# "fielded" search select (pulldown) | |
# label in pulldown is followed by the name of a SOLR request handler as | |
# defined in solr/conf/solrconfig.xml | |
config[:search_fields] ||= [] | |
# Search fields will inherit the :qt solr request handler from | |
# config[:default_solr_parameters], OR can specify a different one | |
# with a :qt key/value. Below examples inherit. | |
# | |
# The :key is what will be used to identify this BL search field internally, | |
# as well as in URLs -- so changing it after deployment may break bookmarked | |
# urls. A display label will be automatically calculated from the :key, | |
# or can be specified manually to be different. | |
config[:search_fields] << { | |
:display_label => 'Any Field', | |
:key => "all_fields", | |
:unstemmed_override => { | |
:solr_local_parameters => { | |
:qf => "$default_qf_unstemmed" | |
} | |
} | |
} | |
config[:search_fields] << {:display_label => 'Title', :key => "title", | |
:solr_local_parameters => { | |
:qf => "$title_qf", | |
:pf => "$title_pf" | |
}, | |
:solr_parameters =>{ | |
:"spellcheck.dictionary" => "title" | |
} | |
} | |
config[:search_fields] << {:display_label => 'Author', :key => "author", | |
:solr_local_parameters => { | |
:qf => "$author_qf", | |
:pf => "$author_pf" | |
}, | |
:solr_parameters => { | |
:"spellcheck.dictionary" => "author" | |
} | |
} | |
config[:search_fields] << {:display_label => 'Subject', :key => "subject", | |
:solr_local_parameters => { | |
:qf => "$subject_qf", | |
:pf => "$subject_pf" | |
}, | |
:solr_parameters => { | |
:"spellcheck.dictionary" => "subject" | |
} | |
} | |
# Combining numbers is weird. Call numbers end up as multiple tokens, | |
# so we use pf/ps/mm to try to make sure call number searches are reasonable | |
# Everything else should just be one token, usually. | |
config[:search_fields] << { | |
:display_label => "Numbers", | |
:key => "number", | |
:solr_local_parameters => { | |
:qf => "$numbers_qf", | |
:pf => "$numbers_pf" | |
}, | |
:solr_parameters => { | |
:mm=>"100%", | |
:ps => "0", | |
:spellcheck => "false" | |
} | |
} | |
config[:search_fields] << {:display_label => 'Series Title', :key=>'series', :qt => 'search', | |
:include_in_simple_select => false, | |
:solr_local_parameters => { | |
:qf => "$series_qf", | |
:pf => "$series_pf" | |
} | |
} | |
#### | |
# Hidden searches. | |
# We don't want ISBN/ISSN/Callnum/Oclcnum/LCCN in our search popup | |
# But we leave them defined here for CQL access, but with | |
# :show_in_simple_select => false | |
config[:search_fields] << {:display_label => "ISBN", :qt => "search", :key =>"isbn", | |
:include_in_simple_select => false, | |
:include_in_advanced_search => false, | |
:solr_parameters => { | |
:qf => "isbn_t", | |
:pf =>"", | |
:spellcheck => "false" | |
} | |
} | |
config[:search_fields] << {:display_label => 'ISSN', :qt => 'issn_search', | |
:key => "issn", | |
:include_in_simple_select => false, | |
:include_in_advanced_search => false, | |
:solr_parameters => { | |
:qf => "issn issn_related", | |
:pf => "", | |
:spellcheck => "false" | |
} | |
} | |
config[:search_fields] << {:display_label => 'OCLC number', :key => "oclcnum", :qt => 'search', | |
:include_in_simple_select => false, | |
:include_in_advanced_search => false, | |
:solr_parameters => { | |
:qf => "oclcnum_t", | |
:pf => "", | |
:spellcheck => "false" | |
} | |
} | |
# cql plugin can't handle the qt=>'standard' thing properly right now. | |
#config[:search_fields] << {:display_label => "LCCN", :qt => "standard", | |
# :include_in_simple_select => false, | |
# :solr_parameters => { | |
# :df => "lccn", | |
# :pf => "", | |
# :spellcheck => "false" | |
# } | |
#} | |
config[:search_fields] << {:display_label => 'Call number', :qt =>"search", | |
:key => "call_number", | |
:include_in_simple_select => false, | |
:solr_parameters => { | |
:qf => "local_call_number_t", | |
:mm=>"100%", | |
:pf =>"local_call_number_t^100", | |
:ps => "0", | |
:spellcheck => "false" | |
} | |
} | |
# "sort results by" select (pulldown) | |
# label in pulldown is followed by the name of the SOLR field to sort by and | |
# whether the sort is ascending or descending (it must be asc or desc | |
# except in the relevancy case). | |
# label is key, solr field is value | |
config[:sort_fields] ||= [] | |
config[:sort_fields] << ['relevance', 'score desc, pub_date_sort desc, title_sort asc'] | |
config[:sort_fields] << ['year', 'pub_date_sort desc, title_sort asc'] | |
config[:sort_fields] << ['author', 'author_sort asc, title_sort asc'] | |
config[:sort_fields] << ['title', 'title_sort asc, pub_date_sort desc'] | |
# If there are more than this many search results, no spelling ("did you | |
# mean") suggestion is offered. | |
config[:spell_max] = 5 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment