diff --git a/app/indexers/concerns/iiif_print/file_set_indexer.rb b/app/indexers/concerns/iiif_print/file_set_indexer.rb index f1c5da4b..0e09c5fc 100644 --- a/app/indexers/concerns/iiif_print/file_set_indexer.rb +++ b/app/indexers/concerns/iiif_print/file_set_indexer.rb @@ -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 diff --git a/app/models/concerns/iiif_print/blacklight_iiif_search/annotation_behavior.rb b/app/models/concerns/iiif_print/blacklight_iiif_search/annotation_behavior.rb index f6cbf05b..a4a3d63a 100644 --- a/app/models/concerns/iiif_print/blacklight_iiif_search/annotation_behavior.rb +++ b/app/models/concerns/iiif_print/blacklight_iiif_search/annotation_behavior.rb @@ -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 diff --git a/lib/generators/iiif_print/blacklight_iiif_search_generator.rb b/lib/generators/iiif_print/blacklight_iiif_search_generator.rb index 5453083d..8fd16de8 100644 --- a/lib/generators/iiif_print/blacklight_iiif_search_generator.rb +++ b/lib/generators/iiif_print/blacklight_iiif_search_generator.rb @@ -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' diff --git a/lib/iiif_print.rb b/lib/iiif_print.rb index 2e3c509e..6a0d2fd0 100644 --- a/lib/iiif_print.rb +++ b/lib/iiif_print.rb @@ -15,6 +15,7 @@ require "iiif_print/tiff_derivative_service" require "iiif_print/metadata" require "iiif_print/works_controller_behavior" +require "iiif_print/catalog_controller_decorator" module IiifPrint extend ActiveSupport::Autoload diff --git a/lib/iiif_print/catalog_controller_decorator.rb b/lib/iiif_print/catalog_controller_decorator.rb new file mode 100644 index 00000000..2ec235c2 --- /dev/null +++ b/lib/iiif_print/catalog_controller_decorator.rb @@ -0,0 +1,26 @@ +module IiifPrint + module CatalogControllerDecorator + # rubocop:disable Metrics/MethodLength + def iiif_search + _parent_response, @parent_document = fetch(params[:solr_document_id]) + iiif_search = ::BlacklightIiifSearch::IiifSearch.new(iiif_search_params, iiif_search_config, + @parent_document) + @response, _document_list = search_results(iiif_search.solr_params) + iiif_search_response = ::BlacklightIiifSearch::IiifSearchResponse.new(@response, + @parent_document, + self) + json_results = iiif_search_response.annotation_list + 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 + + render json: json_results, + content_type: 'application/json' + end + end + # rubocop:enable Metrics/MethodLength +end diff --git a/lib/iiif_print/engine.rb b/lib/iiif_print/engine.rb index 3994c620..d9540701 100644 --- a/lib/iiif_print/engine.rb +++ b/lib/iiif_print/engine.rb @@ -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) + CatalogController.prepend(IiifPrint::CatalogControllerDecorator) # 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.