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 in a new facet solr field for Collection #3261

Merged
merged 5 commits into from
Feb 7, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def self.modified_field
config.advanced_search[:url_key] ||= 'advanced'
config.advanced_search[:query_parser] ||= 'dismax'
config.advanced_search[:form_solr_parameters] ||= {
'facet.field' => %w[non_user_collections_ssim copyright_combined_label_sim date_combined_year_label_ssim institution_label_sim language_label_sim]
'facet.field' => %w[non_user_collections_label_ssim non_user_collections_ssim copyright_combined_label_sim date_combined_year_label_ssim institution_label_sim language_label_sim]
}
config.advanced_search[:form_facet_partial] = 'advanced_search_facets_as_select'

Expand Down Expand Up @@ -213,9 +213,9 @@ def self.modified_field
config.add_facet_field 'location_combined_label_sim', label: I18n.translate('simple_form.labels.defaults.location_combined'), index_range: 'A'..'Z', limit: 5
config.add_facet_field 'workType_label_sim', label: I18n.translate('simple_form.labels.defaults.workType'), index_range: 'A'..'Z', limit: 5
config.add_facet_field 'language_label_sim', label: I18n.translate('simple_form.labels.defaults.language'), index_range: 'A'..'Z', limit: 5
config.add_facet_field 'non_user_collections_ssim', limit: 5, label: 'Collection', helper_method: 'collection_title_from_id', index_range: 'a'..'z'
config.add_facet_field 'non_user_collections_label_ssim', label: 'Collection', helper_method: 'collection_title_from_id', index_range: 'A'..'Z', limit: 5
config.add_facet_field 'local_collection_name_label_sim', label: I18n.translate('simple_form.labels.defaults.local_collection'), index_range: 'A'..'Z', limit: 5
config.add_facet_field 'institution_label_sim', limit: 5, label: 'Institution', index_range: 'A'..'Z'
config.add_facet_field 'institution_label_sim', label: 'Institution', index_range: 'A'..'Z', limit: 5

config.add_facet_field 'cultural_context_label_sim', label: I18n.translate('simple_form.labels.defaults.cultural_context_label'), index_range: 'A'..'Z', limit: 5
config.add_facet_field 'local_contexts_label_sim', label: I18n.translate('simple_form.labels.defaults.local_contexts'), index_range: 'A'..'Z', limit: 5
Expand Down
4 changes: 4 additions & 0 deletions app/indexers/generic_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class GenericIndexer < Hyrax::WorkIndexer
# propogate downwards.
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/BlockLength
def generate_solr_document
super.tap do |solr_doc|
index_rights_statement_label(solr_doc, object)
Expand All @@ -25,13 +26,15 @@ def generate_solr_document
index_local_contexts_label(solr_doc, object)
index_sort_options(solr_doc)
label_fetch_properties_solr_doc(object, solr_doc)
solr_doc['non_user_collections_label_ssim'] = []
solr_doc['non_user_collections_ssim'] = []
solr_doc['user_collections_ssim'] = []
solr_doc['oai_collections_ssim'] = []
object.member_of_collections.each do |collection|
collection_index_key = collection_indexing_key(collection.collection_type.machine_id)
solr_doc[collection_index_key] << collection.id
solr_doc[collection_index_key.gsub('_ssim', '_tesim')] = collection.title
solr_doc['non_user_collections_label_ssim'] << collection.title if collection_index_key == 'non_user_collections_ssim'
end
# removing index_topic_combined_label(solr_doc, object.keyword)
# will be handled when indexing fetched labels
Expand All @@ -47,6 +50,7 @@ def generate_solr_document
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/BlockLength

def collection_indexing_key(machine_id)
case machine_id
Expand Down