diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index 8e2c02837..ac7da93c6 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -159,7 +159,6 @@ class CatalogController < ApplicationController config.add_index_field 'author_meeting_display', label: 'Meeting Author' config.add_index_field 'summary_display', label: 'Description' config.add_index_field 'topic_display', label: 'Topic' - config.add_index_field 'subject_other_display', label: 'Subject' config.add_index_field 'language', label: 'Language' config.add_index_field 'physical', label: 'Physical Description' config.add_index_field 'pub_display', label: 'Publication Info' diff --git a/lib/traject/dor_config.rb b/lib/traject/dor_config.rb index 81127c6ff..92bfe6c79 100644 --- a/lib/traject/dor_config.rb +++ b/lib/traject/dor_config.rb @@ -56,14 +56,49 @@ to_field 'author_person_full_display', stanford_mods(:sw_person_authors) # subject search fields -to_field 'topic_search', stanford_mods(:topic_search) -to_field 'geographic_search', stanford_mods(:geographic_search) -to_field 'subject_other_search', stanford_mods(:subject_other_search) -to_field 'subject_other_subvy_search', stanford_mods(:subject_other_subvy_search) -to_field 'subject_all_search', stanford_mods(:subject_all_search) -to_field 'topic_facet', stanford_mods(:topic_facet) -to_field 'geographic_facet', stanford_mods(:geographic_facet) -to_field 'era_facet', stanford_mods(:era_facet) +to_field 'geographic_search', stanford_mods(:term_values, [:subject, :geographic]) +to_field 'geographic_search', (accumulate { |resource, *_| resource.smods_rec.subject.hierarchicalGeographic }) do |_record, accumulator, _context| + accumulator.map! do |hg_node| + hg_node.element_children.map(&:text).reject(&:empty?).join(' ').strip + end +end + +to_field 'geographic_search', (accumulate { |resource, *_| resource.smods_rec.subject.geographicCode.translated_value }) + +to_field 'topic_search', stanford_mods(:term_values, [:subject, :topic]) +to_field 'topic_search', stanford_mods(:term_values, [:subject, :occupation]) +to_field 'topic_search', stanford_mods(:term_values, [:subject, :name_el]) do |_record, accumulator, _context| + accumulator.reject! { |name_el| name_el.namePart.blank? } + accumulator.map! do |name_el| + name_el.namePart.map(&:text).reject(&:empty?).join(', ').strip + end + accumulator.reject!(&:blank?) +end +to_field 'topic_search', stanford_mods(:term_values, [:subject, :titleInfo]) do |_record, accumulator, _context| + accumulator.map! do |ti_el| + ti_el.element_children.map(&:text).reject(&:empty?).join(' ').strip + end + accumulator.reject!(&:blank?) +end + +to_field 'topic_facet', copy('topic_search') do |_record, accumulator, _context| + accumulator.map! { |v| v.sub(/[\\,;]$/, '').strip } +end + +to_field 'subject_other_subvy_search', stanford_mods(:term_values, [:subject, :temporal]) +to_field 'subject_other_subvy_search', stanford_mods(:term_values, [:subject, :genre]) + +to_field 'subject_all_search', copy('topic_search') +to_field 'subject_all_search', copy('geographic_search') +to_field 'subject_all_search', copy('subject_other_subvy_search') + +to_field 'geographic_facet', copy('geographic_search') do |_record, accumulator, _context| + accumulator.map! { |v| v.sub(/[\\,;]$/, '').strip } +end + +to_field 'era_facet', stanford_mods(:term_values, [:subject, :temporal]) do |_record, accumulator, _context| + accumulator.map! { |v| v.sub(/[\\,;]$/, '').strip } +end to_field 'format_main_ssim', conditional(->(resource, *_) { !resource.collection? }, stanford_mods(:format_main)) diff --git a/solr/config/schema.xml b/solr/config/schema.xml index 3d196d3e1..83b2adc53 100644 --- a/solr/config/schema.xml +++ b/solr/config/schema.xml @@ -283,7 +283,6 @@ - @@ -300,7 +299,6 @@ -