Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #144 from duke-libraries/fix-boost
Browse files Browse the repository at this point in the history
Escape boost param for Solr.
  • Loading branch information
corylown authored Jan 15, 2019
2 parents cee7976 + 1e9939f commit c2f2897
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions app/models/concerns/subjects_boost.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,23 @@ def subjects_english_boost_query
def subjects_title_boost_query
if blacklight_params.key?(:q) &&
blacklight_params[:q].present?
"#{TrlnArgon::Fields::TITLE_MAIN_INDEXED}:(#{blacklight_params[:q]})^500"
standard_search_title_boost
elsif blacklight_params.key?('subject') &&
blacklight_params['subject'].present?
"#{TrlnArgon::Fields::TITLE_MAIN_INDEXED}:"\
"(#{blacklight_params['subject']})^500"
advanced_search_title_boost
end
end

def standard_search_title_boost
"#{TrlnArgon::Fields::TITLE_MAIN_INDEXED}:"\
"(#{RSolr.solr_escape(blacklight_params[:q])})^500"
end

def advanced_search_title_boost
"#{TrlnArgon::Fields::TITLE_MAIN_INDEXED}:"\
"(#{RSolr.solr_escape(blacklight_params['subject'])})^500"
end

def includes_subject_search?
blacklight_params.key?('search_field') &&
((blacklight_params['search_field'] == 'subject' ||
Expand Down
2 changes: 1 addition & 1 deletion lib/dul_argon_skin/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module DulArgonSkin
VERSION = '1.0.2'
VERSION = '1.0.3'
end

0 comments on commit c2f2897

Please sign in to comment.