-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1876 from samvera/1875-collection-full-text-search
add filesets to search for collection show page
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/search_builders/hyrax/collection_member_search_builder_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |