diff --git a/.env b/.env index 540f0aacf..8c4081a82 100644 --- a/.env +++ b/.env @@ -14,12 +14,11 @@ FCREPO_BASE_PATH=/hykudemo FCREPO_HOST=fcrepo FCREPO_PORT=8080 FCREPO_REST_PATH=rest -HYRAX_ACTIVE_JOB_QUEUE=good_job +HYRAX_ACTIVE_JOB_QUEUE=sidekiq HYRAX_FITS_PATH=/app/fits/fits.sh INITIAL_ADMIN_EMAIL=admin@example.com INITIAL_ADMIN_PASSWORD=testing123 IN_DOCKER=true -JAVA_OPTS= JAVA_OPTS=-Xmx4g -Xms1g LD_LIBRARY_PATH=/opt/fits/tools/mediainfo/linux NEGATIVE_CAPTCHA_SECRET=default-value-change-me diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index e6d67c2d1..148fc234b 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -74,7 +74,7 @@ def self.uploaded_field config.search_builder_class = IiifPrint::CatalogSearchBuilder # Use locally customized AdvSearchBuilder so we can enable blacklight_advanced_search - # TODO ROB config.search_builder_class = AdvSearchBuilder + config.search_builder_class = AdvSearchBuilder # Show gallery view config.view.gallery.partials = %i[index_header index] @@ -206,7 +206,6 @@ def self.uploaded_field # since we aren't specifying it otherwise. config.add_search_field('all_fields', label: 'All Fields', include_in_advanced_search: false) do |field| all_names = config.show_fields.values.map(&:field).join(" ") - title_name = 'title_tesim' field.solr_parameters = { qf: "#{all_names} file_format_tesim all_text_timv", @@ -235,7 +234,6 @@ def self.uploaded_field end config.add_search_field('creator') do |field| - # TODO: ROB field.label = "Author" field.solr_parameters = { "spellcheck.dictionary": "creator" } solr_name = 'creator_tesim' field.solr_local_parameters = { diff --git a/app/search_builders/adv_search_builder.rb b/app/search_builders/adv_search_builder.rb new file mode 100644 index 000000000..92e486f11 --- /dev/null +++ b/app/search_builders/adv_search_builder.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class AdvSearchBuilder < IiifPrint::CatalogSearchBuilder + include Blacklight::Solr::SearchBuilderBehavior + include BlacklightAdvancedSearch::AdvancedSearchBuilder + + # A Solr param filter that is NOT included by default in the chain, + # but is appended by AdvancedController#index, to do a search + # for facets _ignoring_ the current query, we want the facets + # as if the current query weren't there. + # + # Also adds any solr params set in blacklight_config.advanced_search[:form_solr_parameters] + def facets_for_advanced_search_form(solr_p) + # ensure empty query is all records, to fetch available facets on entire corpus + solr_p["q"] = '{!lucene}*:*' + # explicitly use lucene defType since we are passing a lucene query above (and appears to be required for solr 7) + solr_p["defType"] = 'lucene' + # We only care about facets, we don't need any rows. + solr_p["rows"] = "0" + + # Anything set in config as a literal + solr_p.merge!(blacklight_config.advanced_search[:form_solr_parameters]) if blacklight_config.advanced_search[:form_solr_parameters] + end +end diff --git a/spec/search_builders/adv_search_builder_spec.rb b/spec/search_builders/adv_search_builder_spec.rb new file mode 100644 index 000000000..f7352edec --- /dev/null +++ b/spec/search_builders/adv_search_builder_spec.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +RSpec.describe AdvSearchBuilder do + let(:scope) do + double(blacklight_config: CatalogController.blacklight_config, + current_ability: ability) + end + let(:user) { create(:user) } + let(:ability) { ::Ability.new(user) } + let(:access) { :read } + let(:builder) { described_class.new(scope).with_access(access) } + + it "can be instantiated" do + expect(builder).to be_instance_of(described_class) + end + + describe ".default_processor_chain" do + subject { described_class.default_processor_chain } + + let(:expected_default_processor_chain) do + # Yes there's a duplicate for add_access_controls_to_solr_params; but that does not appear to + # be causing a problem like the duplication and order of the now removed additional + # :add_advanced_parse_q_to_solr, :add_advanced_search_to_solr filters. Those existed in their + # current position and at the end of the array. + # + # When we had those duplicates, the :add_advanced_parse_q_to_solr obliterated the join logic + # for files. + # + # Is the order immutable? No. But it does highlight that you must consider what the changes + # might mean and double check that join logic on files. + %i[ + default_solr_parameters + add_search_field_default_parameters + add_query_to_solr + add_facet_fq_to_solr + add_facetting_to_solr + add_solr_fields_to_query + add_paging_to_solr + add_sorting_to_solr + add_group_config_to_solr + add_facet_paging_to_solr + add_adv_search_clauses + add_additional_filters + add_range_limit_params + add_access_controls_to_solr_params + filter_models + only_active_works + add_advanced_parse_q_to_solr + add_advanced_search_to_solr + add_access_controls_to_solr_params + show_works_or_works_that_contain_files + show_only_active_records + filter_collection_facet_for_access + exclude_models + highlight_search_params + show_parents_only + include_allinson_flex_fields + ] + end + + it { is_expected.to eq(expected_default_processor_chain) } + end +end