Skip to content

Commit

Permalink
i3943: don't send left_anchor field through the advanced_parser
Browse files Browse the repository at this point in the history
The blacklight advanced search gem was being overly helpful,
noticing that there were a set of parentheses in the query:

  Washington post (Washington, D.C. : 1877)

And accordingly, it parsed it into the following nested
query, which caused a Solr error:

  _query_:"{!edismax }Washington post" AND _query_:"{!edismax }Washington, D.C. : 1877"*
  • Loading branch information
sandbergja committed Jan 22, 2024
1 parent 3f9c465 commit 93fc623
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ class CatalogController < ApplicationController
qf: '$left_anchor_qf',
pf: '$left_anchor_pf'
}
field.advanced_parse = false
end

config.add_search_field('publisher') do |field|
Expand Down
6 changes: 6 additions & 0 deletions spec/requests/catalog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
expect(response.status).to eq(200)
end

it 'can handle parentheses in the left_anchor field' do
get '/?search_field=left_anchor&q=Washington+post+(Washington%2C+D.C.+%3A+1877)'

expect(response.status).to eq(200)
end

context "BadRequest when clicking back to search" do
# This url produces ActionController::BadRequest
let(:url) do
Expand Down

0 comments on commit 93fc623

Please sign in to comment.