diff --git a/app/search_builders/concerns/iiif_print/allinson_flex_fields.rb b/app/search_builders/concerns/iiif_print/allinson_flex_fields.rb new file mode 100644 index 00000000..8cf94aff --- /dev/null +++ b/app/search_builders/concerns/iiif_print/allinson_flex_fields.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module IiifPrint + module AllinsonFlexFields + def include_allinson_flex_fields(solr_parameters) + return unless defined?(AllinsonFlex) + + solr_parameters[:qf] += IiifPrint.allinson_flex_fields + .each_with_object([]) do |field, arr| + arr << (field.name + '_tesim') if field.is_a?(AllinsonFlex::ProfileProperty) + end + .join(' ') + end + end +end diff --git a/app/search_builders/concerns/iiif_print/iiif_search_builder_decorator.rb b/app/search_builders/concerns/iiif_print/iiif_search_builder_decorator.rb new file mode 100644 index 00000000..c3c36bec --- /dev/null +++ b/app/search_builders/concerns/iiif_print/iiif_search_builder_decorator.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +# OVERRIDE BlacklightIiifSearch v1.0.0 to include AllinsonFlex fields in the search + +module IiifPrint + module IiifSearchBuilderDecorator + # NOTE: ::IiifSearchBuilder.default_processor_chain += [:include_allinson_flex_fields] + # is on the engine.rb file so this decorator is loaded before the `default_processor_chain` is set. + include IiifPrint::AllinsonFlexFields + end +end diff --git a/lib/iiif_print/catalog_search_builder.rb b/lib/iiif_print/catalog_search_builder.rb index 506c6026..e230881a 100644 --- a/lib/iiif_print/catalog_search_builder.rb +++ b/lib/iiif_print/catalog_search_builder.rb @@ -11,12 +11,16 @@ class CatalogSearchBuilder < Hyrax::CatalogSearchBuilder include IiifPrint::HighlightSearchParams # TODO: Do we need the following as a module? It hides the behavior include IiifPrint::ExcludeModels + include IiifPrint::AllinsonFlexFields # NOTE: If you are using advanced_search, the :exclude_models and :highlight_search_params must # be added after the advanced_search methods (which are not part of this gem). In other tests, # we found that having the advanced search processing after the two aforementioned processors # resulted in improper evaluation of keyword querying. - self.default_processor_chain += [:exclude_models, :highlight_search_params, :show_parents_only] + self.default_processor_chain += [:exclude_models, + :highlight_search_params, + :show_parents_only, + :include_allinson_flex_fields] # rubocop:enable Naming/PredicateName def show_parents_only(solr_parameters) diff --git a/lib/iiif_print/engine.rb b/lib/iiif_print/engine.rb index 1330f20a..d24b78da 100644 --- a/lib/iiif_print/engine.rb +++ b/lib/iiif_print/engine.rb @@ -51,6 +51,8 @@ class Engine < ::Rails::Engine ::BlacklightIiifSearch::IiifSearchResponse.prepend(IiifPrint::IiifSearchResponseDecorator) ::BlacklightIiifSearch::IiifSearchAnnotation.prepend(IiifPrint::BlacklightIiifSearch::AnnotationDecorator) ::BlacklightIiifSearch::IiifSearch.prepend(IiifPrint::IiifSearchDecorator) + ::IiifSearchBuilder.prepend(IiifPrint::IiifSearchBuilderDecorator) + ::IiifSearchBuilder.default_processor_chain += [:include_allinson_flex_fields] Hyrax::Actors::FileSetActor.prepend(IiifPrint::Actors::FileSetActorDecorator) Hyrax.config do |config|