blacklight 9.0.0.beta7 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.docker/app/Dockerfile +2 -1
- data/.github/matrix.json +21 -20
- data/README.md +2 -2
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.esm.js +13 -7
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +13 -7
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/components/blacklight/advanced_search_form_component.rb +2 -1
- data/app/components/blacklight/document_component.rb +10 -13
- data/app/components/blacklight/facets/filters_component.rb +2 -2
- data/app/components/blacklight/facets/suggest_component.html.erb +17 -12
- data/app/components/blacklight/facets/suggest_component.rb +2 -3
- data/app/components/blacklight/metadata_field_component.html.erb +2 -2
- data/app/components/blacklight/metadata_field_component.rb +2 -1
- data/app/components/blacklight/metadata_field_layout_component.rb +9 -4
- data/app/components/blacklight/search_bar_component.html.erb +1 -1
- data/app/controllers/concerns/blacklight/catalog.rb +3 -4
- data/app/javascript/blacklight-frontend/checkbox_submit.js +2 -2
- data/app/javascript/blacklight-frontend/facet_suggest.js +4 -1
- data/app/javascript/blacklight-frontend/modal.js +7 -4
- data/app/presenters/blacklight/document_presenter.rb +6 -5
- data/app/presenters/blacklight/facet_field_presenter.rb +10 -3
- data/app/presenters/blacklight/field_presenter.rb +4 -2
- data/app/presenters/blacklight/rendering/abstract_step.rb +7 -1
- data/app/presenters/blacklight/rendering/join.rb +9 -5
- data/app/presenters/blacklight/rendering/terminator.rb +1 -1
- data/app/services/blacklight/search_service.rb +4 -2
- data/app/views/catalog/_show_main_content.html.erb +9 -5
- data/app/views/catalog/index.html.erb +0 -1
- data/app/views/catalog/show.html.erb +2 -2
- data/config/locales/blacklight.en.yml +1 -1
- data/lib/blacklight/component.rb +2 -0
- data/lib/blacklight/configuration/facet_field.rb +2 -0
- data/lib/blacklight/configuration/view_config.rb +30 -16
- data/lib/blacklight/configuration.rb +56 -9
- data/lib/blacklight/routes/searchable.rb +1 -1
- data/lib/blacklight/search_builder.rb +160 -1
- data/lib/blacklight/search_state/pivot_filter_field.rb +1 -1
- data/lib/blacklight/solr/field_reflection_search_builder.rb +11 -0
- data/lib/blacklight/solr/repository.rb +5 -5
- data/lib/blacklight/solr/search_builder_behavior.rb +73 -7
- data/lib/blacklight/solr/single_doc_search_builder.rb +25 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +27 -5
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -67
- data/package.json +1 -1
- data/spec/components/blacklight/document_component_spec.rb +0 -7
- data/spec/components/blacklight/facets/filters_component_spec.rb +3 -3
- data/spec/components/blacklight/facets/suggest_component_spec.rb +14 -1
- data/spec/components/blacklight/search_bar_component_spec.rb +24 -1
- data/spec/controllers/blacklight/catalog_spec.rb +1 -1
- data/spec/features/advanced_search_spec.rb +39 -20
- data/spec/features/facets_spec.rb +9 -0
- data/spec/models/blacklight/configuration_spec.rb +126 -0
- data/spec/models/blacklight/search_builder_spec.rb +11 -1
- data/spec/models/blacklight/solr/repository_spec.rb +6 -0
- data/spec/models/blacklight/solr/search_builder_behavior_spec.rb +214 -8
- data/spec/presenters/blacklight/document_presenter_spec.rb +3 -3
- data/spec/presenters/blacklight/field_presenter_spec.rb +103 -22
- data/spec/presenters/blacklight/rendering/pipeline_spec.rb +130 -14
- metadata +8 -16
- data/app/controllers/concerns/blacklight/facetable.rb +0 -34
- data/app/models/facet_search_builder.rb +0 -5
- data/app/services/blacklight/facet_search_service.rb +0 -44
- data/app/views/shared/_sitelinks_search_box.html.erb +0 -12
- data/lib/blacklight/abstract_search_builder.rb +0 -154
- data/lib/blacklight/facet_search_builder.rb +0 -18
- data/lib/blacklight/solr/facet_search_builder_behavior.rb +0 -62
- data/spec/features/sitelinks_search_box_spec.rb +0 -13
- data/spec/models/blacklight/facet_search_builder_spec.rb +0 -19
- data/spec/models/blacklight/solr/facet_search_builder_behavior_spec.rb +0 -929
|
@@ -98,73 +98,6 @@
|
|
|
98
98
|
</arr>
|
|
99
99
|
</requestHandler>
|
|
100
100
|
|
|
101
|
-
<requestHandler name="/advanced" class="solr.SearchHandler">
|
|
102
|
-
<!-- a lucene request handler for using the JSON Query DSL,
|
|
103
|
-
specifically for advanced search.
|
|
104
|
-
Using a separate requestHandler is a workaround to
|
|
105
|
-
https://issues.apache.org/jira/browse/SOLR-16916, although
|
|
106
|
-
it could be desirable for other reasons as well.
|
|
107
|
-
-->
|
|
108
|
-
<lst name="defaults">
|
|
109
|
-
<str name="defType">lucene</str>
|
|
110
|
-
<str name="echoParams">explicit</str>
|
|
111
|
-
<str name="df">title_tsim</str>
|
|
112
|
-
<str name="qf">
|
|
113
|
-
id
|
|
114
|
-
full_title_tsim
|
|
115
|
-
short_title_tsim
|
|
116
|
-
alternative_title_tsim
|
|
117
|
-
title_tsim
|
|
118
|
-
author_tsim
|
|
119
|
-
subject_tsim
|
|
120
|
-
all_text_timv
|
|
121
|
-
</str>
|
|
122
|
-
<str name="pf">
|
|
123
|
-
all_text_timv^10
|
|
124
|
-
</str>
|
|
125
|
-
|
|
126
|
-
<str name="author_qf">
|
|
127
|
-
author_tsim
|
|
128
|
-
</str>
|
|
129
|
-
<str name="author_pf">
|
|
130
|
-
</str>
|
|
131
|
-
<str name="title_qf">
|
|
132
|
-
title_tsim
|
|
133
|
-
full_title_tsim
|
|
134
|
-
short_title_tsim
|
|
135
|
-
alternative_title_tsim
|
|
136
|
-
</str>
|
|
137
|
-
<str name="title_pf">
|
|
138
|
-
</str>
|
|
139
|
-
<str name="subject_qf">
|
|
140
|
-
subject_tsim
|
|
141
|
-
</str>
|
|
142
|
-
<str name="subject_pf">
|
|
143
|
-
</str>
|
|
144
|
-
|
|
145
|
-
<str name="fl">
|
|
146
|
-
*,
|
|
147
|
-
score
|
|
148
|
-
</str>
|
|
149
|
-
|
|
150
|
-
<str name="facet">true</str>
|
|
151
|
-
<str name="facet.mincount">1</str>
|
|
152
|
-
<str name="facet.limit">10</str>
|
|
153
|
-
<str name="facet.field">subject_ssim</str>
|
|
154
|
-
|
|
155
|
-
<str name="spellcheck">true</str>
|
|
156
|
-
<str name="spellcheck.dictionary">default</str>
|
|
157
|
-
<str name="spellcheck.onlyMorePopular">true</str>
|
|
158
|
-
<str name="spellcheck.extendedResults">true</str>
|
|
159
|
-
<str name="spellcheck.collate">false</str>
|
|
160
|
-
<str name="spellcheck.count">5</str>
|
|
161
|
-
|
|
162
|
-
</lst>
|
|
163
|
-
<arr name="last-components">
|
|
164
|
-
<str>spellcheck</str>
|
|
165
|
-
</arr>
|
|
166
|
-
</requestHandler>
|
|
167
|
-
|
|
168
101
|
<requestHandler name="permissions" class="solr.SearchHandler" >
|
|
169
102
|
<lst name="defaults">
|
|
170
103
|
<str name="facet">off</str>
|
data/package.json
CHANGED
|
@@ -136,13 +136,6 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
136
136
|
vc_test_controller.action_name = "show"
|
|
137
137
|
end
|
|
138
138
|
|
|
139
|
-
it 'renders with an id' do
|
|
140
|
-
component.with_body { '-' }
|
|
141
|
-
render_inline component
|
|
142
|
-
|
|
143
|
-
expect(page).to have_css 'article#document'
|
|
144
|
-
end
|
|
145
|
-
|
|
146
139
|
it 'renders a title' do
|
|
147
140
|
render_inline component
|
|
148
141
|
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
5
|
RSpec.describe Blacklight::Facets::FiltersComponent, type: :component do
|
|
6
|
-
let(:facet_field) { Blacklight::Configuration::FacetField.new key: 'language_facet', suggest
|
|
6
|
+
let(:facet_field) { Blacklight::Configuration::FacetField.new key: 'language_facet', suggest?: true }
|
|
7
7
|
let(:presenter) do
|
|
8
8
|
instance_double(Blacklight::FacetFieldPresenter, facet_field: facet_field, label: 'Lang',
|
|
9
|
-
view_context: view_context, suggest
|
|
9
|
+
view_context: view_context, suggest?: true, key: 'lang')
|
|
10
10
|
end
|
|
11
11
|
let(:view_context) { vc_test_controller.view_context }
|
|
12
12
|
|
|
@@ -22,7 +22,7 @@ RSpec.describe Blacklight::Facets::FiltersComponent, type: :component do
|
|
|
22
22
|
let(:component) { described_class.new(presenter: presenter) }
|
|
23
23
|
|
|
24
24
|
it 'draws default classes' do
|
|
25
|
-
expect(page).to have_css(".facet-filters.
|
|
25
|
+
expect(page).to have_css(".facet-filters.mt-1.mb-3")
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -37,7 +37,7 @@ RSpec.describe Blacklight::Facets::SuggestComponent, type: :component do
|
|
|
37
37
|
with_request_url "/catalog/facet/language_facet" do
|
|
38
38
|
rendered = render_inline component
|
|
39
39
|
label = rendered.css('label').first
|
|
40
|
-
expect(label.text.strip).to eq 'Filter
|
|
40
|
+
expect(label.text.strip).to eq 'Filter languages'
|
|
41
41
|
|
|
42
42
|
id_in_label_for = label.attribute('for').text
|
|
43
43
|
expect(id_in_label_for).to eq('facet_suggest_language_facet')
|
|
@@ -58,6 +58,7 @@ RSpec.describe Blacklight::Facets::SuggestComponent, type: :component do
|
|
|
58
58
|
|
|
59
59
|
context 'when the facet is not explicitly configured with a suggest key' do
|
|
60
60
|
let(:facet) { Blacklight::Configuration::FacetField.new key: 'language_facet' }
|
|
61
|
+
let(:presenter) { Blacklight::FacetFieldPresenter.new(facet, nil, vc_test_controller.view_context, nil) }
|
|
61
62
|
|
|
62
63
|
it 'displays' do
|
|
63
64
|
with_request_url "/catalog/facet/language_facet" do
|
|
@@ -65,5 +66,17 @@ RSpec.describe Blacklight::Facets::SuggestComponent, type: :component do
|
|
|
65
66
|
expect(rendered.css("input.facet-suggest").count).to eq 1
|
|
66
67
|
end
|
|
67
68
|
end
|
|
69
|
+
|
|
70
|
+
context "with blacklight_config.default_facet_suggest = false" do
|
|
71
|
+
before do
|
|
72
|
+
allow(vc_test_controller.view_context.blacklight_config).to receive(:default_facet_suggest).and_return(false)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'does not display' do
|
|
76
|
+
with_request_url "/catalog/facet/language_facet" do
|
|
77
|
+
expect(render_inline(component).to_s).to eq ''
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
68
81
|
end
|
|
69
82
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
5
|
RSpec.describe Blacklight::SearchBarComponent, type: :component do
|
|
6
|
-
let(:instance) { described_class.new(url: search_action_url, params: params_for_search) }
|
|
6
|
+
let(:instance) { described_class.new(url: search_action_url, params: params_for_search, advanced_search_url: '/advanced') }
|
|
7
7
|
|
|
8
8
|
let(:search_action_url) { '/catalog' }
|
|
9
9
|
let(:params_for_search) { { q: 'testParamValue' } }
|
|
@@ -104,4 +104,27 @@ RSpec.describe Blacklight::SearchBarComponent, type: :component do
|
|
|
104
104
|
expect(render.css('.rounded-0')).to be_present
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
|
+
|
|
108
|
+
context 'advanced search link' do
|
|
109
|
+
subject(:render) { render_inline(instance) }
|
|
110
|
+
|
|
111
|
+
context 'when enabled (default)' do
|
|
112
|
+
it 'renders the advanced search link' do
|
|
113
|
+
expect(render.css("a.advanced_search.btn.btn-link[href='/advanced']")).to be_present
|
|
114
|
+
expect(render.css("a.advanced_search").text).to eq('Advanced search')
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
context 'when disabled via configuration' do
|
|
119
|
+
let(:blacklight_config) do
|
|
120
|
+
Blacklight::Configuration.new.configure do |config|
|
|
121
|
+
config.advanced_search.enabled = false
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it 'does not render the advanced search link' do
|
|
126
|
+
expect(render.css("a.advanced_search")).not_to be_present
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
107
130
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
RSpec.describe Blacklight::Catalog do
|
|
4
4
|
subject { controller }
|
|
5
5
|
|
|
6
|
-
let(:controller) {
|
|
6
|
+
let(:controller) { Class.new(ApplicationController) { include Blacklight::Catalog }.new }
|
|
7
7
|
|
|
8
8
|
describe "#search_state" do
|
|
9
9
|
subject { controller.send(:search_state) }
|
|
@@ -5,25 +5,7 @@ require 'spec_helper'
|
|
|
5
5
|
RSpec.describe "Blacklight Advanced Search Form" do
|
|
6
6
|
describe "advanced search form" do
|
|
7
7
|
before do
|
|
8
|
-
|
|
9
|
-
edismax: {}
|
|
10
|
-
}
|
|
11
|
-
CatalogController.blacklight_config.search_fields['author']['clause_params'] = {
|
|
12
|
-
edismax: { qf: '${author_qf}' }
|
|
13
|
-
}
|
|
14
|
-
CatalogController.blacklight_config.search_fields['title']['clause_params'] = {
|
|
15
|
-
edismax: { qf: '${title_qf}' }
|
|
16
|
-
}
|
|
17
|
-
CatalogController.blacklight_config.search_fields['subject']['clause_params'] = {
|
|
18
|
-
edismax: { qf: '${subject_qf}' }
|
|
19
|
-
}
|
|
20
|
-
visit '/catalog/advanced?hypothetical_existing_param=true&q=ignore+this+existing+query'
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
after do
|
|
24
|
-
%w[all_fields author title subject].each do |field|
|
|
25
|
-
CatalogController.blacklight_config.search_fields[field].delete(:clause_params)
|
|
26
|
-
end
|
|
8
|
+
visit '/catalog/advanced'
|
|
27
9
|
end
|
|
28
10
|
|
|
29
11
|
it "has field and facet blocks" do
|
|
@@ -56,6 +38,16 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
56
38
|
expect(page).to have_content 'Language'
|
|
57
39
|
end
|
|
58
40
|
end
|
|
41
|
+
|
|
42
|
+
it "omits facets configured with include_in_advanced_search: false" do
|
|
43
|
+
expect(page).to have_no_css('.blacklight-example_pivot_field')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "lists all the values for an included facet" do
|
|
47
|
+
within('.blacklight-subject_ssim') do
|
|
48
|
+
expect(page).to have_css('ul.facet-values li', count: 45)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
59
51
|
end
|
|
60
52
|
|
|
61
53
|
it 'scopes searches to fields' do
|
|
@@ -66,6 +58,14 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
66
58
|
expect(page).to have_css('article.document', count: 1)
|
|
67
59
|
end
|
|
68
60
|
|
|
61
|
+
it 'does not render spellcheck/did you mean? section' do
|
|
62
|
+
fill_in 'All Fields', with: 'tibet'
|
|
63
|
+
click_on 'advanced-search-submit'
|
|
64
|
+
expect(page).to have_content 'Remove constraint All Fields: tibet'
|
|
65
|
+
expect(page).to have_css('article.document', count: 2)
|
|
66
|
+
expect(page).to have_no_css('#spell')
|
|
67
|
+
end
|
|
68
|
+
|
|
69
69
|
it 'can limit to facets' do
|
|
70
70
|
fill_in 'Subject', with: 'Women'
|
|
71
71
|
click_on 'Language'
|
|
@@ -107,7 +107,7 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
107
107
|
|
|
108
108
|
describe "prepopulated advanced search form" do
|
|
109
109
|
before do
|
|
110
|
-
visit '/catalog/advanced?op=must&clause[1][field]=title&clause[1]query=medicine&f_inclusive[language_ssim][]=Tibetan&sort=author'
|
|
110
|
+
visit '/catalog/advanced?op=must&clause[1][field]=title&clause[1]query=medicine&f_inclusive[language_ssim][]=Tibetan&f[format][]=Book&sort=author'
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
it 'prepopulates the expected fields' do
|
|
@@ -117,6 +117,12 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
117
117
|
expect(page).to have_select 'sort', selected: 'author'
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
+
it 'creates hidden inputs for fields not included in the advanced search form' do
|
|
121
|
+
within('form.advanced') do
|
|
122
|
+
expect(page).to have_field 'f[format][]', type: :hidden, with: 'Book'
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
120
126
|
it "does not create hidden inputs for fields included in adv search form" do
|
|
121
127
|
within('form.advanced') do
|
|
122
128
|
expect(page).to have_no_field('clause[1][query]', type: :hidden, with: 'medicine')
|
|
@@ -140,5 +146,18 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
140
146
|
expect(page).to have_no_field 'Title', with: 'medicine'
|
|
141
147
|
expect(page).to have_no_field 'Tibetan', checked: true
|
|
142
148
|
end
|
|
149
|
+
|
|
150
|
+
it 'creates constraints for fields not included in advanced search form' do
|
|
151
|
+
within('div.constraints') do
|
|
152
|
+
expect(page).to have_content('Format:Book')
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
it 'does not create constraints for fields included in the advanced search form' do
|
|
157
|
+
within('div.constraints') do
|
|
158
|
+
expect(page).to have_no_content('Title:medicine')
|
|
159
|
+
expect(page).to have_no_content('Language:Tibetan')
|
|
160
|
+
end
|
|
161
|
+
end
|
|
143
162
|
end
|
|
144
163
|
end
|
|
@@ -112,6 +112,15 @@ RSpec.describe "Facets" do
|
|
|
112
112
|
expect(page).to have_css 'a.facet-select', count: 2
|
|
113
113
|
end
|
|
114
114
|
|
|
115
|
+
it 'can show suggestions including a period', :js do
|
|
116
|
+
visit '/catalog/facet/subject_ssim'
|
|
117
|
+
fill_in 'facet_suggest_subject_ssim', with: 'iran.'
|
|
118
|
+
|
|
119
|
+
expect(page).to have_css '.facet-suggestions'
|
|
120
|
+
expect(page).to have_link 'Iran. Vizārat-i Kishvar'
|
|
121
|
+
expect(page).to have_css 'a.facet-select', count: 1
|
|
122
|
+
end
|
|
123
|
+
|
|
115
124
|
it 'shows the user facet suggestions that are relevant to their q param', :js do
|
|
116
125
|
visit '/catalog/facet/subject_ssim?q=tibet&search_field=all_fields'
|
|
117
126
|
fill_in 'facet_suggest_subject_ssim', with: 'la'
|
|
@@ -735,4 +735,130 @@ RSpec.describe Blacklight::Configuration, :api do
|
|
|
735
735
|
described_class.default_configuration.delete_at(2)
|
|
736
736
|
end
|
|
737
737
|
end
|
|
738
|
+
|
|
739
|
+
describe "#copy_search_field_config_to_advanced!" do
|
|
740
|
+
let(:config) { described_class.new }
|
|
741
|
+
|
|
742
|
+
before do
|
|
743
|
+
config.add_search_field('title',
|
|
744
|
+
solr_parameters: {
|
|
745
|
+
'spellcheck.dictionary': 'title',
|
|
746
|
+
qf: '${title_qf}',
|
|
747
|
+
pf: '${title_pf}'
|
|
748
|
+
})
|
|
749
|
+
config.add_search_field('excluded_field',
|
|
750
|
+
solr_parameters: { qf: '${excluded_qf}' },
|
|
751
|
+
include_in_advanced_search: false)
|
|
752
|
+
config.add_search_field('already_configured',
|
|
753
|
+
solr_parameters: { qf: '${configured_qf}' },
|
|
754
|
+
clause_params: { edismax: { existing_custom: 'params' } })
|
|
755
|
+
end
|
|
756
|
+
|
|
757
|
+
it "copies solr_parameters to clause_params for eligible search fields" do
|
|
758
|
+
config.copy_search_field_config_to_advanced!
|
|
759
|
+
|
|
760
|
+
title_field = config.search_fields['title']
|
|
761
|
+
expect(title_field.clause_params).to be_present
|
|
762
|
+
expect(title_field.clause_params[:edismax]).to eq({ 'spellcheck.dictionary': 'title', qf: '${title_qf}', pf: '${title_pf}' })
|
|
763
|
+
end
|
|
764
|
+
|
|
765
|
+
it "skips fields with include_in_advanced_search set to false" do
|
|
766
|
+
config.copy_search_field_config_to_advanced!
|
|
767
|
+
|
|
768
|
+
excluded_field = config.search_fields['excluded_field']
|
|
769
|
+
expect(excluded_field.clause_params).to be_nil
|
|
770
|
+
end
|
|
771
|
+
|
|
772
|
+
it "skips fields that already have a clause_params config" do
|
|
773
|
+
config.copy_search_field_config_to_advanced!
|
|
774
|
+
|
|
775
|
+
already_configured_field = config.search_fields['already_configured']
|
|
776
|
+
expect(already_configured_field.clause_params).to eq({ edismax: { existing_custom: 'params' } })
|
|
777
|
+
end
|
|
778
|
+
|
|
779
|
+
it "handles fields with nil solr_parameters" do
|
|
780
|
+
config.add_search_field('no_solr_params')
|
|
781
|
+
|
|
782
|
+
expect { config.copy_search_field_config_to_advanced! }.not_to raise_error
|
|
783
|
+
|
|
784
|
+
field = config.search_fields['no_solr_params']
|
|
785
|
+
expect(field.clause_params).to be_present
|
|
786
|
+
expect(field.clause_params[:edismax]).to eq({})
|
|
787
|
+
end
|
|
788
|
+
end
|
|
789
|
+
|
|
790
|
+
describe "#copy_facet_field_config_to_advanced!" do
|
|
791
|
+
let(:config) { described_class.new }
|
|
792
|
+
|
|
793
|
+
before do
|
|
794
|
+
config.add_facet_field('format',
|
|
795
|
+
field: 'format')
|
|
796
|
+
config.add_facet_field('subject_ssim')
|
|
797
|
+
config.add_facet_field('excluded_facet',
|
|
798
|
+
field: 'excluded_field',
|
|
799
|
+
include_in_advanced_search: false)
|
|
800
|
+
config.add_facet_field('query_facet',
|
|
801
|
+
query: { 'recent' => { fq: 'pub_date_ssim:[2020 TO *]' } })
|
|
802
|
+
config.add_facet_field('pivot_facet',
|
|
803
|
+
pivot: %w[author_ssim subject_ssim])
|
|
804
|
+
config.add_facet_field('range_facet',
|
|
805
|
+
range: true,
|
|
806
|
+
field: 'pub_date_ssim')
|
|
807
|
+
end
|
|
808
|
+
|
|
809
|
+
it "sets default facet.sort to 'count'" do
|
|
810
|
+
config.copy_facet_field_config_to_advanced!
|
|
811
|
+
|
|
812
|
+
expect(config.advanced_search.form_solr_parameters['facet.sort']).to eq 'count'
|
|
813
|
+
end
|
|
814
|
+
|
|
815
|
+
it "adds eligible facet fields to facet.field array" do
|
|
816
|
+
config.copy_facet_field_config_to_advanced!
|
|
817
|
+
|
|
818
|
+
facet_fields = config.advanced_search.form_solr_parameters['facet.field']
|
|
819
|
+
expect(facet_fields).to eq(%w[format subject_ssim])
|
|
820
|
+
end
|
|
821
|
+
|
|
822
|
+
it "skips fields with include_in_advanced_search set to false" do
|
|
823
|
+
config.copy_facet_field_config_to_advanced!
|
|
824
|
+
|
|
825
|
+
facet_fields = config.advanced_search.form_solr_parameters['facet.field']
|
|
826
|
+
expect(facet_fields).not_to include('excluded_field')
|
|
827
|
+
end
|
|
828
|
+
|
|
829
|
+
it "skips fields that are query, pivot, or range facets" do
|
|
830
|
+
config.copy_facet_field_config_to_advanced!
|
|
831
|
+
|
|
832
|
+
facet_fields = config.advanced_search.form_solr_parameters['facet.field']
|
|
833
|
+
expect(facet_fields).not_to include('query_facet', 'pivot_facet', 'range_facet')
|
|
834
|
+
end
|
|
835
|
+
|
|
836
|
+
it "sets facet limit to -1 to show all values for eligible fields" do
|
|
837
|
+
config.copy_facet_field_config_to_advanced!
|
|
838
|
+
|
|
839
|
+
expect(config.advanced_search.form_solr_parameters['f.format.facet.limit']).to eq(-1)
|
|
840
|
+
expect(config.advanced_search.form_solr_parameters['f.subject_ssim.facet.limit']).to eq(-1)
|
|
841
|
+
end
|
|
842
|
+
|
|
843
|
+
context "preserving existing advanced search config if present" do
|
|
844
|
+
before do
|
|
845
|
+
config.advanced_search.form_solr_parameters = {
|
|
846
|
+
'facet.sort' => 'index',
|
|
847
|
+
'f.subject_ssim.facet.limit' => 50
|
|
848
|
+
}
|
|
849
|
+
end
|
|
850
|
+
|
|
851
|
+
it "preserves existing facet.limit configuration if set" do
|
|
852
|
+
config.copy_facet_field_config_to_advanced!
|
|
853
|
+
|
|
854
|
+
expect(config.advanced_search.form_solr_parameters['f.subject_ssim.facet.limit']).to eq(50)
|
|
855
|
+
end
|
|
856
|
+
|
|
857
|
+
it "preserves existing default facet.sort configuration if set" do
|
|
858
|
+
config.copy_facet_field_config_to_advanced!
|
|
859
|
+
|
|
860
|
+
expect(config.advanced_search.form_solr_parameters['facet.sort']).to eq('index')
|
|
861
|
+
end
|
|
862
|
+
end
|
|
863
|
+
end
|
|
738
864
|
end
|
|
@@ -125,7 +125,7 @@ RSpec.describe Blacklight::SearchBuilder, :api do
|
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
subject.with(a: 1)
|
|
128
|
-
expect(subject.
|
|
128
|
+
expect(subject.processed_parameters).to include step_1: 'builder'
|
|
129
129
|
end
|
|
130
130
|
end
|
|
131
131
|
|
|
@@ -225,6 +225,16 @@ RSpec.describe Blacklight::SearchBuilder, :api do
|
|
|
225
225
|
end
|
|
226
226
|
end
|
|
227
227
|
|
|
228
|
+
describe "#facet_suggestion_query" do
|
|
229
|
+
it "is nil if no value is set" do
|
|
230
|
+
expect(subject.facet_suggestion_query).to be_nil
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
it "sets facet_suggestion_query value" do
|
|
234
|
+
expect(subject.facet_suggestion_query('antel').facet_suggestion_query).to eq 'antel'
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
|
|
228
238
|
describe "#search_field" do
|
|
229
239
|
it "uses the requested search field" do
|
|
230
240
|
blacklight_config.add_search_field 'x'
|
|
@@ -87,6 +87,12 @@ RSpec.describe Blacklight::Solr::Repository, :api do
|
|
|
87
87
|
expect(subject.search(params: {})).to be_a Blacklight::Solr::Response
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
+
it "can be called with no args" do
|
|
91
|
+
blacklight_config.solr_path = 'xyz'
|
|
92
|
+
allow(subject.connection).to receive(:send_and_receive).with('xyz', anything).and_return(mock_response)
|
|
93
|
+
expect(subject.search).to be_a Blacklight::Solr::Response
|
|
94
|
+
end
|
|
95
|
+
|
|
90
96
|
it "uses the default solr path" do
|
|
91
97
|
allow(subject.connection).to receive(:send_and_receive).with('select', anything).and_return(mock_response)
|
|
92
98
|
expect(subject.search(params: {})).to be_a Blacklight::Solr::Response
|