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

[WIP] Unpack stanford-mods subject macros #934

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
51 changes: 43 additions & 8 deletions lib/traject/dor_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
2 changes: 0 additions & 2 deletions solr/config/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@
<copyField source="topic_subx_search" dest="topic_subx_unstem_search" />
<copyField source="geographic_search" dest="geographic_unstem_search" />
<copyField source="geographic_subz_search" dest="geographic_subz_unstem_search" />
<copyField source="subject_other_search" dest="subject_other_unstem_search" />
<copyField source="subject_other_subvy_search" dest="subject_other_subvy_unstem_search" />
<copyField source="subject_all_search" dest="subject_all_unstem_search" />
<!-- unstemmed search fields: toc/summary -->
Expand All @@ -300,7 +299,6 @@

<!-- image fields -->
<copyField source="topic_search" dest="topic_display" />
<copyField source="subject_other_search" dest="subject_other_display" />
<copyField source="title_variant_search" dest="title_variant_display" />
<copyField source="summary_search" dest="summary_display" />
<copyField source="pub_search" dest="pub_display" />
Expand Down