Created
June 16, 2011 20:36
-
-
Save jrochkind/1030209 to your computer and use it in GitHub Desktop.
UnstemSolrParams
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
# lib/unstem_solr_params.rb | |
# Add on to CatalogController or another SolrHelper | |
#, to support :unstem_search param to search only un-stemmed fields. | |
module UnstemSolrParams | |
def self.included(klass) | |
# Replace :add_query_to_solr in solr_search_params_logic with | |
# our new method. | |
i = klass.solr_search_params_logic << :add_unstemmed_overrides_to_solr | |
end | |
## | |
# If unstemmed_search is selected, then we add params to redefine | |
# things like $author_qf, $title_qf, etc.. Normally those are supplied | |
# by Solr solrconfig.xml defaults, but we define em explicitly in the | |
# request to contain only unstemmed fields. | |
def add_unstemmed_overrides_to_solr(solr_parameters, user_parameters) | |
if user_parameters[:unstemmed_search] | |
Blacklight.config[:unstemmed_overrides].each_pair do |key, value| | |
solr_parameters[key] = value | |
end | |
end | |
return solr_parameters | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment