Skip to content

Commit

Permalink
Merge pull request #263 from scientist-softserv/allinson-flex-solr-query
Browse files Browse the repository at this point in the history
🎁 Add `AllinsonFlex` fields to solr queries
  • Loading branch information
kirkkwang authored Jul 17, 2023
2 parents cba4d90 + e4ba835 commit 0c3edc4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
15 changes: 15 additions & 0 deletions app/search_builders/concerns/iiif_print/allinson_flex_fields.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion lib/iiif_print/catalog_search_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions lib/iiif_print/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down

0 comments on commit 0c3edc4

Please sign in to comment.