Skip to content

Commit 0e12a84

Browse files
authored
Allow advanced search to return results when no query is present (#3810)
1 parent 5b5d78b commit 0e12a84

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

lib/blacklight/solr/search_builder_behavior.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def add_search_field_with_json_query_parameters(solr_parameters)
102102

103103
# Transform "clause" parameters into the Solr JSON Query DSL
104104
def add_adv_search_clauses(solr_parameters)
105-
return if search_state.clause_params.blank?
105+
return if search_state.clause_params.blank? || search_state.clause_params.all? { |_k, v| v[:query].blank? }
106106

107107
# We need to specify lucene as the top-level defType when using JSON Query DSL in Solr versions
108108
# between 7.2.0 & 9.4.0. After 9.4.0 this is no longer necessary, but also not harmful to include.

spec/features/advanced_search_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@
103103
expect(page).to have_content('Pākistānī ʻaurat dorāhe par')
104104
expect(page).to have_css('article.document', count: 10)
105105
end
106+
107+
it 'returns all records when no query is present' do
108+
click_on 'advanced-search-submit'
109+
expect(page).to have_content('1 - 10 of 30')
110+
end
111+
112+
it 'performs a faceted search when query is present' do
113+
within '#facet-language_ssim' do
114+
check 'Urdu 3'
115+
end
116+
click_on 'advanced-search-submit'
117+
expect(page).to have_css('article.document', count: 3)
118+
end
106119
end
107120

108121
describe "prepopulated advanced search form" do

0 commit comments

Comments
 (0)