Skip to content

Commit

Permalink
Merge pull request #264 from scientist-softserv/fix-ocr-search
Browse files Browse the repository at this point in the history
🐛 Fix bug OCR search bug with AllinsonFlex
  • Loading branch information
kirkkwang authored Jul 18, 2023
2 parents 0c3edc4 + 19232b7 commit 7b82aa3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
10 changes: 5 additions & 5 deletions app/search_builders/concerns/iiif_print/allinson_flex_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ 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(' ')
query_fields = solr_parameters[:qf].split(' ') + IiifPrint.allinson_flex_fields
.each_with_object([]) do |field, arr|
arr << (field.name + '_tesim') if field.is_a?(AllinsonFlex::ProfileProperty)
end
solr_parameters[:qf] = query_fields.uniq.join(' ')
end
end
end

This file was deleted.

8 changes: 8 additions & 0 deletions lib/generators/iiif_print/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,13 @@ def lint_iiif_search_builder
contents.insert(0, "# frozen_string_literal: true\n\n")
File.write(file, contents)
end

def add_allinson_flex_fields_method_to_iiif_search_builder
file_path = "app/models/iiif_search_builder.rb"
contents = File.read(file_path)
contents.gsub!('include Blacklight::Solr::SearchBuilderBehavior', "include Blacklight::Solr::SearchBuilderBehavior\n include IiifPrint::AllinsonFlexFields")
contents.gsub!('self.default_processor_chain += [:ocr_search_params]', 'self.default_processor_chain += %i[ocr_search_params include_allinson_flex_fields]')
File.write(file_path, contents)
end
end
end
2 changes: 0 additions & 2 deletions lib/iiif_print/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ 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 7b82aa3

Please sign in to comment.