Skip to content

Commit

Permalink
Solr 7.2 removed support for inline LocalParams
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Jan 8, 2018
1 parent 67f6fb3 commit a7f788e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
10 changes: 3 additions & 7 deletions lib/blacklight/solr/search_builder_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,11 @@ def add_query_to_solr(solr_parameters)
end

##
# Create Solr 'q' including the user-entered q, prefixed by any
# solr LocalParams in config, using solr LocalParams syntax.
# http://wiki.apache.org/solr/LocalParams
# Create Solr 'q' including the user-entered q, including any search-field-specific parameters
##
if search_field && search_field.solr_local_parameters.present?
local_params = search_field.solr_local_parameters.map do |key, val|
key.to_s + "=" + solr_param_quote(val, quote: "'")
end.join(" ")
solr_parameters[:q] = "{!#{local_params}}#{blacklight_params[:q]}"
solr_parameters.merge!(search_field.solr_local_parameters.symbolize_keys)
solr_parameters[:q] = "#{blacklight_params[:q]}"

##
# Set Solr spellcheck.q to be original user-entered query, without
Expand Down
16 changes: 6 additions & 10 deletions spec/models/blacklight/solr/search_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,9 @@
it "should include spellcheck.dictionary from field def solr_parameters" do
expect(subject[:"spellcheck.dictionary"]).to eq "subject"
end
it "should add on :solr_local_parameters using Solr LocalParams style" do
#q == "{!pf=$subject_pf $qf=subject_qf} wome", make sure
#the LocalParams are really there
subject[:q] =~ /^\{!([^}]+)\}/
key_value_pairs = $1.split(" ")
expect(key_value_pairs).to include("pf=$subject_pf")
expect(key_value_pairs).to include("qf=$subject_qf")
it "should add on :solr_local_parameters" do
expect(subject[:pf]).to eq '$subject_pf'
expect(subject[:qf]).to eq '$subject_qf'
end
end

Expand Down Expand Up @@ -351,9 +347,9 @@
end

it "should include include local params with escaping" do
expect(subject[:q]).to include('qf=$author_qf')
expect(subject[:q]).to include('pf=\'you\\\'ll have \\" to escape this\'')
expect(subject[:q]).to include('pf2=$pf2_do_not_escape_or_quote')
expect(subject[:qf]).to eq('$author_qf')
expect(subject[:pf]).to eq('you\'ll have " to escape this\'')
expect(subject[:pf2]).to eq('$pf2_do_not_escape_or_quote')
end
end

Expand Down

0 comments on commit a7f788e

Please sign in to comment.