Skip to content

Commit

Permalink
Merge pull request #92 from scientist-softserv/i81-uv-text-search
Browse files Browse the repository at this point in the history
[i81] - Fix OCR UV Search
  • Loading branch information
kirkkwang authored Jan 31, 2023
2 parents 0ed30b3 + 1a66d40 commit d5de25c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/indexers/concerns/iiif_print/file_set_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def generate_solr_document
super.tap do |solr_doc|
# only UV viewable images should have is_page_of, it is only used for iiif search
solr_doc['is_page_of_ssim'] = [ancestor_ids(object)] if object.mime_type&.match(/image/)
solr_doc['all_text_tsimv'] = object.extracted_text.content if object.try(:extracted_text).try(:content)&.present?
index_full_text(object, solr_doc)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def base_url
# return the first file set id
# @return [String]
def file_set_id
return document['id'] if document.file_set?

file_set_ids = document['file_set_ids_ssim']
raise "#{self.class}: NO FILE SET ID" if file_set_ids.blank?
file_set_ids.first
Expand Down
17 changes: 17 additions & 0 deletions app/models/iiif_print/iiif_search_response_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module IiifPrint
module IiifSearchResponseDecorator
# Enable the user to search for child metadata in the parent's UV
# @see https://github.com/scientist-softserv/louisville-hyku/commit/67467e5cf9fdb755f54419f17d3c24c87032d0af
def annotation_list
json_results = super
json_results&.[]('resources')&.each do |result_hit|
next if result_hit['resource'].present?
result_hit['resource'] = {
"@type": "cnt:ContentAsText",
"chars": "Metadata match, see sidebar for details"
}
end
json_results
end
end
end
8 changes: 0 additions & 8 deletions lib/generators/iiif_print/blacklight_iiif_search_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ def adjust_catalog_controller_is_page_of_config
" object_relation_field: 'is_page_of_ssim',")
end

# Update the IiifSearchBuilder
def adjust_iiif_search_builder
marker = 'solr_parameters[:hl] = true'
inject_into_file 'app/models/iiif_search_builder.rb', after: marker do
"\n solr_parameters[:qf] = blacklight_config.iiif_search[:full_text_field]"
end
end

def inject_search_behavior
copy_file 'search_behavior.rb',
'app/models/concerns/blacklight_iiif_search/search_behavior.rb'
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 @@ -31,6 +31,8 @@ class Engine < ::Rails::Engine
Hyrax::ManifestBuilderService.prepend(IiifPrint::ManifestBuilderServiceBehavior)
Hyrax::WorksControllerBehavior.prepend(IiifPrint::WorksControllerBehaviorDecorator)
Hyrax::WorkShowPresenter.prepend(IiifPrint::WorkShowPresenterDecorator)
Hyrax::FileSetIndexer.prepend(IiifPrint::FileSetIndexer)
BlacklightIiifSearch::IiifSearchResponse.prepend(IiifPrint::IiifSearchResponseDecorator)

# Extending the presenter to the base url which includes the protocol.
# We need the base url to render the facet links and normalize the interface.
Expand Down

0 comments on commit d5de25c

Please sign in to comment.