Skip to content

Commit

Permalink
Merge pull request #1141 from UNC-Libraries/hyc-1968-affil-fix
Browse files Browse the repository at this point in the history
HYC-1968 - Indexing of affiliations with multiple terms
  • Loading branch information
sharonluong authored Jan 31, 2025
2 parents 021bb1f + cc82181 commit 551a37b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ def add_affiliation(affiliation_relation, display_text)
term = DepartmentsService.term(affiliation_identifier)
if term.present?
display_text << "Affiliation: #{affiliation_identifier}"
term.split(';').each do |term_val|
# ensure term is an array to deal with some affiliations containing multiple term values, while most are single
Array(term).map { |v| v.split(';') }.flatten.each do |term_val|
@affiliation_label.push(term_val.strip)
end
end
Expand Down
22 changes: 22 additions & 0 deletions spec/lib/active_fedora/rdf/indexing_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,28 @@
end
end

context 'when adding person object with affiliation that maps to two terms' do
let(:indexer) { described_class.new(work, work.class.index_config) }
let(:work) do
General.create(
title: ['New General Work with joint affiliation'],
creators_attributes: { '0' => { name: 'creator_1',
affiliation: 'Joint Department of Biomedical Engineering',
index: 1 } },
date_created: '2022-01-01')

end
subject(:solr_doc) do
indexer.generate_solr_document
end

it 'includes person attributes' do
expect(solr_doc['creator_display_tesim']).to eq ['index:1||creator_1||Affiliation: Joint Department of Biomedical Engineering']
expect(solr_doc['affiliation_label_tesim']).to include('School of Medicine', 'North Carolina State University', 'Joint Department of Biomedical Engineering')
expect(solr_doc['affiliation_label_sim']).to include('School of Medicine', 'North Carolina State University', 'Joint Department of Biomedical Engineering')
end
end

context 'with date_created set' do
let(:date_index_config) do
{}.tap do |index_config|
Expand Down

0 comments on commit 551a37b

Please sign in to comment.