Skip to content

Instantly share code, notes, and snippets.

@jrochkind
Created June 16, 2011 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrochkind/1030209 to your computer and use it in GitHub Desktop.
Save jrochkind/1030209 to your computer and use it in GitHub Desktop.
UnstemSolrParams
# 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