Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add filesets to search for collection show page #1876

Merged
merged 2 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)