Skip to content

Commit

Permalink
Merge pull request #1876 from samvera/1875-collection-full-text-search
Browse files Browse the repository at this point in the history
add filesets to search for collection show page
  • Loading branch information
labradford authored Dec 19, 2022
2 parents a7f0064 + 08f02b5 commit 7cdd63e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def self.modified_field
config.default_solr_params = {
qt: "search",
rows: 10,
qf: "title_tesim description_tesim creator_tesim keyword_tesim"
qf: "title_tesim description_tesim creator_tesim keyword_tesim all_text_timv"
}

# Specify which field to use in the tag cloud on the homepage.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# frozen_string_literal: true

# OVERRIDE: Hyrax 3.4.1 adds filesets to search to allow full text search results on the Collection show pages
module Hyrax
module CollectionMemberSearchBuilderDecorator
Hyrax::CollectionMemberSearchBuilder.default_processor_chain += [:show_works_or_works_that_contain_files]

# These methods include the filesets in the search results
def show_works_or_works_that_contain_files(solr_parameters)
return if blacklight_params[:q].blank?
solr_parameters[:user_query] = blacklight_params[:q]
solr_parameters[:q] = new_query
solr_parameters[:defType] = 'lucene'
end

# the {!lucene} gives us the OR syntax
def new_query
"{!lucene}#{interal_query(dismax_query)} #{interal_query(join_for_works_from_files)}"
end

# the _query_ allows for another parser (aka dismax)
def interal_query(query_value)
"_query_:\"#{query_value}\""
end

# the {!dismax} causes the query to go against the query fields
def dismax_query
"{!dismax v=$user_query}"
end

# join from file id to work relationship solrized file_set_ids_ssim
def join_for_works_from_files
"{!join from=#{Hyrax.config.id_field} to=file_set_ids_ssim}#{dismax_query}"
end
end
end

Hyrax::CollectionMemberSearchBuilder.prepend(Hyrax::CollectionMemberSearchBuilderDecorator)

0 comments on commit 7cdd63e

Please sign in to comment.