diff --git a/config/features.rb b/config/features.rb
index a7469425b..bdee32073 100644
--- a/config/features.rb
+++ b/config/features.rb
@@ -30,12 +30,6 @@
group :blacklight_8 do
feature :json_query_dsl,
description: "When on / true, use the JSON query DSL for search fields in the advanced search. When off / false, use query params"
-
- feature :view_components_numismatics,
- description: "When on / true, use the built-in advanced search form for numismatics. When off / false, use the traditional one"
-
- feature :view_components_advanced_search,
- description: "When on / true, use the built-in advanced search form. When off / false, use the traditional one"
end
group :search_and_race do
diff --git a/config/routes.rb b/config/routes.rb
index 559f64896..7b6bc8e47 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -55,8 +55,7 @@
end
end
- mount BlacklightAdvancedSearch::Engine => '/', constraints: DeprecatedAdvancedSearchConstraint.new
- get '/advanced', to: 'catalog#advanced_search', constraints: AdvancedSearchConstraint.new
+ get '/advanced', to: 'catalog#advanced_search'
get '/numismatics', to: 'catalog#numismatics'
devise_for :users,
diff --git a/spec/features/advanced_searching_spec.rb b/spec/features/advanced_searching_spec.rb
index 018017119..3c74896ca 100644
--- a/spec/features/advanced_searching_spec.rb
+++ b/spec/features/advanced_searching_spec.rb
@@ -5,6 +5,7 @@
describe 'advanced searching', advanced_search: true do
before do
stub_holding_locations
+ allow(Flipflop).to receive(:json_query_dsl?).and_return(true)
end
it 'does not have a basic search bar' do
@@ -60,24 +61,18 @@
expect(page).to have_content('Aomen')
end
- context 'with the old advanced search form' do
- before do
- allow(Flipflop).to receive(:view_components_advanced_search?).and_return(false)
- allow(Flipflop).to receive(:json_query_dsl?).and_return(false)
- visit '/advanced'
- end
- it 'can exclude terms from the search' do
- # defaults to keyword
- fill_in(id: 'q1', with: 'gay')
- choose(id: 'op3_NOT')
- # defaults to title
- fill_in(id: 'q3', with: 'RenoOut')
- click_button('advanced-search-submit')
- expect(page.find(".page_entries").text).to eq('1 entry found')
- expect(page).to have_content('Seeking sanctuary')
- expect(page).to have_content('Title NOT RenoOut')
- expect(page).not_to have_content('Reno Gay Press and Promotions')
- end
+ it 'can exclude terms from the search' do
+ visit '/advanced'
+ # defaults to keyword
+ fill_in(id: 'clause_0_query', with: 'gay')
+ choose(id: 'clause_2_op_must_not')
+ # defaults to title
+ fill_in(id: 'clause_2_query', with: 'RenoOut')
+ click_button('advanced-search-submit')
+ expect(page.find(".page_entries").text).to eq('1 entry found')
+ expect(page).to have_content('Seeking sanctuary')
+ expect(page).to have_content('Title NOT RenoOut')
+ expect(page).not_to have_content('Reno Gay Press and Promotions')
end
context 'when editing the search', js: true do
@@ -95,7 +90,6 @@
context 'with the built-in advanced search form' do
before do
- allow(Flipflop).to receive(:view_components_advanced_search?).and_return(true)
allow(Flipflop).to receive(:json_query_dsl?).and_return(true)
visit '/advanced'
end
diff --git a/spec/features/more_in_this_series_spec.rb b/spec/features/more_in_this_series_spec.rb
index 2f7a365e3..dd94d3cfe 100644
--- a/spec/features/more_in_this_series_spec.rb
+++ b/spec/features/more_in_this_series_spec.rb
@@ -6,25 +6,8 @@
before do
stub_holding_locations
end
- context 'with the BlacklightAdvancedSearch gem' do
- before do
- allow(Flipflop).to receive(:view_components_advanced_search?).and_return(false)
- allow(Flipflop).to receive(:json_query_dsl?).and_return(false)
- end
-
- it 'does not appear for 490 series titles' do
- visit '/catalog/9955253113506421'
- expect(page.all('a.more-in-series').length).to eq 0
- end
- it 'link to search for 8xx series titles' do
- visit '/catalog/9946871913506421'
- expect(page.all('a.more-in-series').length).to eq 2
- all('a.more-in-series').first.click
- expect(page.body).to include('/catalog/9946871913506421')
- end
- end
- context 'without the BlacklightAdvancedSearch gem' do
+ context 'with the built-in advanced search' do
let(:search_builder_without_gem) do
SearchBuilder.default_processor_chain - [:add_advanced_search_to_solr]
end
@@ -32,7 +15,6 @@
search_builder_without_gem
stub_holding_locations
allow(SearchBuilder).to receive(:default_processor_chain).and_return(search_builder_without_gem)
- allow(Flipflop).to receive(:view_components_advanced_search?).and_return(true)
allow(Flipflop).to receive(:json_query_dsl?).and_return(true)
end
diff --git a/spec/helpers/blacklight_advanced_search/parsing_nesting_spec.rb b/spec/helpers/blacklight_advanced_search/parsing_nesting_spec.rb
deleted file mode 100644
index 07a19953b..000000000
--- a/spec/helpers/blacklight_advanced_search/parsing_nesting_spec.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-# frozen_string_literal: true
-
-require 'rails_helper'
-
-RSpec.describe BlacklightAdvancedSearch::ParsingNestingParser do
- describe '#process_query' do
- subject(:queries) { process_query(_params, config) }
-
- let(:_params) { instance_double(ActiveSupport::HashWithIndifferentAccess) }
- let(:config) { Class.new }
- let(:advanced_search) { instance_double(Blacklight::OpenStructWithHashAccess) }
- let(:keyword_queries) do
- {
- 'title' => 'anything',
- 'all_fields' => '(something) OR (anything)'
- }
- end
-
- before do
- allow(config).to receive(:advanced_search).and_return(advanced_search)
- allow(config).to receive(:search_fields).and_return(keyword_queries)
- allow(self).to receive(:local_param_hash).with('all_fields', config).and_return({})
- allow(self).to receive(:local_param_hash).with('title', config).and_return("spellcheck.dictionary": 'title', qf: '$title_qf', pf: '$title_pf')
- allow(self).to receive(:keyword_op).and_return([])
- allow(self).to receive(:keyword_queries).and_return(keyword_queries)
- end
-
- it 'appends the operators to the queries' do
- allow(advanced_search).to receive(:[]).with(:query_parser).and_return('edismax')
- expect(queries).to include('_query_:"{!edismax spellcheck.dictionary=title qf=$title_qf pf=$title_pf}anything" _query_:"{!dismax mm=1}something anything"')
- end
-
- context 'when the query parser is not specified in the advanced search' do
- let(:advanced_search) { nil }
-
- before do
- allow(Blacklight.logger).to receive(:error)
- end
-
- it 'logs an error and returns an empty query' do
- expect(queries).to be_empty
- expect(Blacklight.logger).to have_received(:error).with(/Failed to parse the advanced search, config\. settings are not accessible for\:/)
- end
- end
-
- context 'there are invalid keyword queries' do
- let(:keyword_queries) do
- {
- 'title' => '(Yu pu za shuo) AND ("")',
- 'all_fields' => '(something) OR (anything)'
- }
- end
-
- before do
- allow(Rails.logger).to receive(:warn)
- end
-
- it 'parses only the valid queries and logs a warning' do
- allow(advanced_search).to receive(:[]).with(:query_parser).and_return('edismax')
- expect(queries).to eq '_query_:"{!dismax mm=1}something anything" '
- expect(Rails.logger).to have_received(:warn).with('Failed to parse the query: (Yu pu za shuo) AND (""): Extra input after last repetition at line 1 char 21.')
- end
- end
- end
-end
diff --git a/spec/helpers/blacklight_advanced_search/query_parser_spec.rb b/spec/helpers/blacklight_advanced_search/query_parser_spec.rb
deleted file mode 100644
index 5385a8b90..000000000
--- a/spec/helpers/blacklight_advanced_search/query_parser_spec.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# frozen_string_literal: true
-
-require 'rails_helper'
-
-describe BlacklightAdvancedSearch::QueryParser do
- describe '#keyword_queries' do
- subject(:query_parser) { described_class.new(params, config) }
-
- let(:blacklight_config) { Blacklight::Configuration.new }
- let(:params) do
- {
- 'utf8' => '✓',
- 'f1' => 'title',
- 'q1' => 'Yu pu za shuo',
- 'op2' => 'AND',
- 'f2' => 'title',
- 'q2' => '""',
- 'op3' => 'AND',
- 'f3' => 'title',
- 'q3' => '',
- 'range' => {
- 'pub_date_start_sort' => {
- 'begin' => '',
- 'end' => ''
- }
- },
- 'sort' => 'score desc, pub_date_start_sort desc, title_sort asc',
- 'search_field' => 'advanced',
- 'commit' => 'Search',
- 'controller' => 'errors',
- 'action' => 'error'
- }
- end
-
- it 'generates the keyword queries' do
- expect(query_parser.keyword_queries).to be_a Hash
- expect(query_parser.keyword_queries).to include('title' => '(Yu pu za shuo) AND ("")')
- end
-
- describe '#keyword query with NOT' do
- let(:params) do
- {
- 'utf8' => '✓',
- 'f1' => 'title',
- 'q1' => 'Yu pu za shuo',
- 'op2' => 'NOT',
- 'f2' => 'title',
- 'q2' => '""',
- 'op3' => 'NOT',
- 'f3' => 'title',
- 'q3' => '',
- 'range' => {
- 'pub_date_start_sort' => {
- 'begin' => '',
- 'end' => ''
- }
- },
- 'sort' => 'score desc, pub_date_start_sort desc, title_sort asc',
- 'search_field' => 'advanced',
- 'commit' => 'Search',
- 'controller' => 'errors',
- 'action' => 'error'
- }
- end
-
- it 'generates the keyword query with NOTs' do
- expect(query_parser.keyword_queries).to be_a Hash
- expect(query_parser.keyword_queries).to include('title' => '(Yu pu za shuo) NOT ("")')
- end
- end
- end
-end
diff --git a/spec/models/search_builder_spec.rb b/spec/models/search_builder_spec.rb
index e83e3ff17..be96eec83 100644
--- a/spec/models/search_builder_spec.rb
+++ b/spec/models/search_builder_spec.rb
@@ -85,10 +85,6 @@
let(:solr_parameters) do
{ q: 'solr AND blacklight' }
end
- it 'parses the query' do
- subject.cleanup_boolean_operators(solr_parameters)
- expect(solr_parameters[:q]).to eq('+solr +blacklight')
- end
end
context 'when q contains an all-caps phrase that happens to contain a boolean operator' do
let(:solr_parameters) do
@@ -138,28 +134,12 @@
context 'with the built-in advanced search form', advanced_search: true do
before do
- allow(Flipflop).to receive(:view_components_advanced_search?).and_return(true)
allow(Flipflop).to receive(:json_query_dsl?).and_return(true)
end
it 'includes the advanced search facets' do
solr_p = { fq: ["{!lucene}{!query v=$f_inclusive.issue_denomination_s.0} OR {!query v=$f_inclusive.issue_denomination_s.1}", nil, "format:Coin"] }
- search_builder.facets_for_advanced_search_form(solr_p)
- expect(solr_p[:fq]).to eq(['format:Coin'])
- end
- end
- context 'with the gem advanced search form' do
- before do
- allow(Flipflop).to receive(:view_components_advanced_search?).and_return(false)
- allow(Flipflop).to receive(:json_query_dsl?).and_return(false)
- end
-
- context 'when encountering a nil facet' do
- it 'removes nil and facets that need to be displayed on the form' do
- solr_p = { fq: ["{!lucene}{!query v=$f_inclusive.issue_denomination_s.0} OR {!query v=$f_inclusive.issue_denomination_s.1}", nil, "format:Coin"] }
- search_builder.facets_for_advanced_search_form(solr_p)
- expect(solr_p[:fq]).to eq(['format:Coin'])
- end
+ expect(solr_p[:fq]).to include('format:Coin')
end
end
end
diff --git a/spec/processors/orangelight/series_link_processor_spec.rb b/spec/processors/orangelight/series_link_processor_spec.rb
index 4761773c4..4dd7cb676 100644
--- a/spec/processors/orangelight/series_link_processor_spec.rb
+++ b/spec/processors/orangelight/series_link_processor_spec.rb
@@ -13,44 +13,8 @@
let(:processor) { described_class.new(values, config, document, {}, options, stack) }
let(:rendered) { processor.render }
- context 'with the old advanced search' do
+ context 'with the built-in advanced search' do
before do
- allow(Flipflop).to receive(:view_components_advanced_search?).and_return(false)
- allow(Flipflop).to receive(:json_query_dsl?).and_return(false)
- end
- it 'adds links if they also appear in the more_in_this_series_t field' do
- expect(rendered.first).to eq('Offenbach, Jacques, 1819-1880. Operas. Selections (Bourg) '\
- ''\
- '[More in this series]')
- end
-
- it "does not add links if they don't appear in the more_in_this_series_t field" do
- expect(rendered.second).to eq('Collection Archive')
- end
-
- context 'empty more_in_this_series_t field' do
- let(:document) { SolrDocument.new }
- it 'does not add links' do
- expect(rendered.first).to eq('Offenbach, Jacques, 1819-1880. Operas. Selections (Bourg)')
- end
- end
-
- context 'more_in_this_series_t contains a shorter version of the series title' do
- let(:document) { SolrDocument.new({ 'more_in_this_series_t': ['Offenbach, Jacques, 1819-1880. Operas'] }) }
- it 'adds the link' do
- expect(rendered.first).to eq('Offenbach, Jacques, 1819-1880. Operas. Selections (Bourg) '\
- ''\
- '[More in this series]')
- end
- end
- end
- context 'without the blacklight advanced search gem' do
- before do
- allow(Flipflop).to receive(:view_components_advanced_search?).and_return(true)
allow(Flipflop).to receive(:json_query_dsl?).and_return(true)
end
it 'adds links if they also appear in the more_in_this_series_t field' do
diff --git a/spec/requests/left_anchor_spec.rb b/spec/requests/left_anchor_spec.rb
index 7a3cd3eb2..9d69ada33 100644
--- a/spec/requests/left_anchor_spec.rb
+++ b/spec/requests/left_anchor_spec.rb
@@ -58,25 +58,6 @@
end
end
- context 'solr operator characters' do
- # These tests are only relevant for the standard query parser
- # # TODO: remove for standard dsl deprecation
- before do
- allow(Flipflop).to receive(:json_query_dsl?).and_return(false)
- allow(Flipflop).to receive(:view_components_advanced_search?).and_return(false)
- end
- it 'are handled in simple search' do
- get '/catalog.json?search_field=left_anchor&q=JSTOR%7B%7D%3A%26%26%7C%7C"%2B%5E~-%2F%3F+%5BElectronic+Resource%5D'
- r = JSON.parse(response.body)
- expect(r['data'].any? { |d| d['id'] == '9928379683506421' }).to eq true
- end
- it 'are handled in advanced search' do
- get '/catalog.json?f1=left_anchor&q1=JSTOR%7B%7D%3A%26%26%7C%7C"%2B%5E~-%2F%3F+%5BElectronic+Resource%5D&search_field=advanced'
- r = JSON.parse(response.body)
- expect(r['data'].any? { |d| d['id'] == '9928379683506421' }).to eq true
- end
- end
-
context 'cjk characters' do
it 'are searchable in simple search' do
get "/catalog.json?search_field=left_anchor&q=#{CGI.escape('浄名玄論 / 京都国立博物館編 ; 解說石塚晴道 (北海道大学名誉教授)')}"
diff --git a/spec/requests/request_spec.rb b/spec/requests/request_spec.rb
index b8f928095..3fe2e189d 100644
--- a/spec/requests/request_spec.rb
+++ b/spec/requests/request_spec.rb
@@ -16,14 +16,6 @@
end
end
- describe 'advanced handling when multiple fields' do
- it 'handles it' do
- get '/catalog.json?f1=title&f2=author&f3=title&op2=AND&op3=AND&q1=&q2=Murakami%2C+Haruki&q3=1Q84&search_field=advanced'
- r = JSON.parse(response.body)
- expect(r['data'].length).to eq 3
- end
- end
-
describe 'NOT tests' do
it 'ignores lowercase' do
get '/catalog.json?search_field=all_fields&q=demeter+does+not+remember'
@@ -380,8 +372,11 @@
end
describe 'series_display in search results' do
+ before do
+ allow(Flipflop).to receive(:json_query_dsl?).and_return(true)
+ end
it 'is fetched when doing a more in this series search' do
- get '/catalog.json?q1=Always+learning.&f1=in_series&search_field=advanced'
+ get '/catalog.json?clause%5B0%5D%5Bfield%5D=series_title&clause%5B0%5D%5Bquery%5D=Always+learning'
r = JSON.parse(response.body)
expect(r['data'].find { |d| d['id'] == '9979171923506421' }['attributes']['series_display']).not_to be_nil
end
@@ -390,7 +385,7 @@
get '/catalog/9979171923506421/raw'
r = JSON.parse(response.body)
series_title = r['series_display']
- get '/catalog?q3=Always+learning&f3=series_title&search_field=advanced'
+ get '/catalog?clause%5B0%5D%5Bquery%5D=Always+learning&clause%5B0%5D%5Bfield%5D=series_title&search_field=advanced'
expect(response.body).to include(series_title.join(', '))
end
it 'is not included in other search contexts' do
@@ -401,8 +396,11 @@
end
describe 'notes field in advanced search' do
+ before do
+ allow(Flipflop).to receive(:json_query_dsl?).and_return(true)
+ end
it 'record with notes field is retrieved' do
- get '/catalog.json?q1=minhas+entre&f1=notes&search_field=advanced'
+ get '/catalog.json?clause%5B0%5D%5Bfield%5D=notes&clause%5B0%5D%5Bquery%5D=minhas+entre&clause%5B1%5D%5Bop%5D=must&clause%5B1%5D%5Bfield%5D=author&clause%5B1%5D%5Bquery%5D=&clause%5B2%5D%5Bop%5D=must&clause%5B2%5D%5Bfield%5D=title&clause%5B2%5D%5Bquery%5D=&range%5Bpub_date_start_sort%5D%5Bbegin%5D=&range%5Bpub_date_start_sort%5D%5Bend%5D=&commit=Search'
r = JSON.parse(response.body)
expect(r['data'].count { |d| d['id'] == '991639143506421' }).to eq(1)
end
@@ -416,6 +414,9 @@
end
describe 'numismatics advanced search' do
+ before do
+ allow(Flipflop).to receive(:json_query_dsl?).and_return(true)
+ end
it 'only returns coin records' do
get '/catalog.json?advanced_type=numismatics&q=*'
r = JSON.parse(response.body)
@@ -455,12 +456,10 @@
end
end
- context "advanced search and jsonld are enabled" do
+ context "with the built-in advanced search and jsonld is enabled" do
before do
allow(Flipflop).to receive(:json_query_dsl?).and_return(true)
- allow(Flipflop).to receive(:view_components_advanced_search?).and_return(true)
end
-
# TODO: what should this really do? Should the advanced search and jsonld get turned off when an algorithm is swapped
# Should we see if we can combine the search handlers by adding a query parameter, or make a combined handler that has both?
it "retuns the jsonld result not the engineering result" do
diff --git a/spec/system/left_anchor_spec.rb b/spec/system/left_anchor_spec.rb
index acc512a20..473f8c6e7 100644
--- a/spec/system/left_anchor_spec.rb
+++ b/spec/system/left_anchor_spec.rb
@@ -50,18 +50,8 @@
RSpec.describe 'left anchored searching', type: :system, left_anchor: true do
before { stub_holding_locations }
- context 'old query dsl and advanced search' do
- before do
- allow(Flipflop).to receive(:view_components_advanced_search?).and_return(false)
- allow(Flipflop).to receive(:json_query_dsl?).and_return(false)
- end
-
- it_behaves_like 'a simple search'
- it_behaves_like 'an advanced search'
- end
context 'new query dsl and advanced search' do
before do
- allow(Flipflop).to receive(:view_components_advanced_search?).and_return(true)
allow(Flipflop).to receive(:json_query_dsl?).and_return(true)
end
diff --git a/spec/system/numismatics_form_spec.rb b/spec/system/numismatics_form_spec.rb
index 080bb5d49..55076b6bc 100644
--- a/spec/system/numismatics_form_spec.rb
+++ b/spec/system/numismatics_form_spec.rb
@@ -5,25 +5,6 @@
before do
stub_alma_holding_locations
end
- context 'when using the view components numismatics form' do
- before { allow(Flipflop).to_receive(:view_components_numismatics?).and_return(true) }
- end
- it 'does not display the basic search form' do
- visit '/numismatics'
- expect(page).not_to have_selector('.search-query-form')
- end
- it 'can run a search', js: true do
- visit '/numismatics'
- fill_in 'issue_denomination_s', with: 'she'
- find('li', text: /shekel/).click
- click_button('advanced-search-submit')
- expect(page.find(".page_entries").text).to eq('1 entry found')
- expect(page).to have_content('Coin: 1167')
- end
-
- context 'when using the original numismatics form' do
- before { allow(Flipflop).to_receive(:view_components_numismatics?).and_return(false) }
- end
it 'does not display the basic search form' do
visit '/numismatics'
expect(page).not_to have_selector('.search-query-form')
diff --git a/spec/system/searching_spec.rb b/spec/system/searching_spec.rb
index cab76e39e..26acbfe60 100644
--- a/spec/system/searching_spec.rb
+++ b/spec/system/searching_spec.rb
@@ -103,6 +103,9 @@
end
context 'searching for series title from advanced search' do
+ before do
+ allow(Flipflop).to receive(:json_query_dsl?).and_return(true)
+ end
it 'displays the online availability' do
visit 'advanced'
select('Series title', from: 'Options for advanced search')
@@ -122,8 +125,11 @@
end
end
context 'with an invalid field list parameter in the advanced search' do
+ before do
+ allow(Flipflop).to receive(:json_query_dsl?).and_return(true)
+ end
it 'will return results without an error' do
- visit '/catalog?q1=NSF%20Series&search_field=advanced&f1=in_series2121121121212.1'
+ visit '/catalog?clause%5B0%5D%5Bfield%5D=series_title&clause%5B0%5D%5Bquery%5D=in_series2121121121212.1'
expect { page }.not_to raise_error
expect(page).to have_content 'No results found for your search'
expect(page).to have_link('Try Borrow Direct', href: 'https://princeton-borrowdirect.reshare.indexdata.com/Search/Results')
@@ -166,7 +172,6 @@
context 'with the built-in advanced search form', advanced_search: true do
before do
- allow(Flipflop).to receive(:view_components_advanced_search?).and_return(true)
allow(Flipflop).to receive(:json_query_dsl?).and_return(true)
end
@@ -201,7 +206,7 @@
in_the_library = page.first('.dropdown-item')
in_the_library.click
click_on('advanced-search-submit')
- page.first('.navbar-toggler').click
+ page.first('.collapse-toggle').click
expect(page).to have_content(/Any of:\nIn the Library/)
end
@@ -218,7 +223,7 @@
it 'shows facets on the advanced search results page' do
visit '/advanced'
- fill_in 'clause_0_query', with: 'robots'
+ fill_in 'clause_0_query', with: 'cats'
click_button 'Search'
expect(page).to have_button('Access')
expect(page).to have_button('Library')
diff --git a/spec/system/skip_links_spec.rb b/spec/system/skip_links_spec.rb
index 6b5308e25..cfe7deb32 100644
--- a/spec/system/skip_links_spec.rb
+++ b/spec/system/skip_links_spec.rb
@@ -33,7 +33,6 @@
end
context 'with the new advanced search' do
before do
- allow(Flipflop).to receive(:view_components_advanced_search?).and_return(true)
allow(Flipflop).to receive(:json_query_dsl?).and_return(true)
end
it 'advanced search page has only one skip link' do
diff --git a/spec/views/catalog/index_spec.rb b/spec/views/catalog/index_spec.rb
index 45cf09532..f46c74c71 100644
--- a/spec/views/catalog/index_spec.rb
+++ b/spec/views/catalog/index_spec.rb
@@ -75,7 +75,7 @@
it 'inclusive facets display when applied' do
visit '/catalog?f_inclusive%5Bformat%5D%5B%5D=Audio&search_field=advanced'
expect(page).to have_selector('.blacklight-format.facet-limit-active')
- expect(page).to have_selector('.advanced_facet_limit')
+ expect(page).to have_selector('.inclusive_or.card')
end
end
end