Skip to content

Commit

Permalink
Convert our generated catalog controller configuration to be compatib…
Browse files Browse the repository at this point in the history
…le with Solr 7.2
  • Loading branch information
cbeer committed Jan 8, 2018
1 parent 67f6fb3 commit a1f3696
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
29 changes: 12 additions & 17 deletions lib/generators/blacklight/templates/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,35 +137,30 @@ class <%= controller_name.classify %>Controller < ApplicationController

config.add_search_field('title') do |field|
# solr_parameters hash are sent to Solr as ordinary url query params.
field.solr_parameters = { :'spellcheck.dictionary' => 'title' }

# :solr_local_parameters will be sent using Solr LocalParams
# syntax, as eg {! qf=$title_qf }. This is neccesary to use
# Solr parameter de-referencing like $title_qf.
# See: http://wiki.apache.org/solr/LocalParams
field.solr_local_parameters = {
qf: '$title_qf',
pf: '$title_pf'
field.solr_parameters = {
'spellcheck.dictionary': 'title',
qf: '${title_qf}',
pf: '${title_pf}'
}
end

config.add_search_field('author') do |field|
field.solr_parameters = { :'spellcheck.dictionary' => 'author' }
field.solr_local_parameters = {
qf: '$author_qf',
pf: '$author_pf'
field.solr_parameters = {
'spellcheck.dictionary': 'author',
qf: '${author_qf}',
pf: '${author_pf}'
}
end

# Specifying a :qt only to show it's possible, and so our internal automated
# tests can test it. In this case it's the same as
# config[:default_solr_parameters][:qt], so isn't actually neccesary.
config.add_search_field('subject') do |field|
field.solr_parameters = { :'spellcheck.dictionary' => 'subject' }
field.qt = 'search'
field.solr_local_parameters = {
qf: '$subject_qf',
pf: '$subject_pf'
field.solr_parameters = {
'spellcheck.dictionary': 'subject',
qf: '${subject_qf}',
pf: '${subject_pf}'
}
end

Expand Down
8 changes: 8 additions & 0 deletions spec/models/blacklight/solr/search_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@
describe "solr parameters for a field search from config (subject)" do
let(:user_params) { subject_search_params }

before do
# The tests below expect pre-solr-7.2 queries with local params
blacklight_config.search_fields['subject'].solr_local_parameters = {
qf: '$subject_qf',
pf: '$subject_pf'
}
end

it "should look up qt from field definition" do
expect(subject[:qt]).to eq "search"
end
Expand Down

0 comments on commit a1f3696

Please sign in to comment.