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

Do not index : for invalid call numbers #2619

Merged
merged 2 commits into from
Feb 10, 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
6 changes: 5 additions & 1 deletion marc_to_solr/lib/traject_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,12 @@
if record['050'] && (record['050']['a'])
first_letter = record['050']['a'].lstrip.slice(0, 1)
letters = /([[:alpha:]])*/.match(record['050']['a'])[0]
map_first = Traject::TranslationMap.new('callnumber_map')[first_letter]
map_rest = Traject::TranslationMap.new('callnumber_map')[letters]
accumulator << Traject::TranslationMap.new('callnumber_map')[first_letter]
accumulator << "#{Traject::TranslationMap.new('callnumber_map')[first_letter]}:#{Traject::TranslationMap.new('callnumber_map')[letters]}"
if map_first && map_rest
accumulator << "#{Traject::TranslationMap.new('callnumber_map')[first_letter]}:#{Traject::TranslationMap.new('callnumber_map')[letters]}"
end
end
end

Expand Down
7 changes: 7 additions & 0 deletions spec/marc_to_solr/lib/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,9 @@ def fixture_record(fixture_name, indexer: @indexer)
end

describe 'lc_facet' do
let(:t050) { { '050' => { 'ind1' => '0', 'ind2' => '0', 'subfields' => [{ 'a' => 'IN PROCESS' }] } } }
let(:record) { @indexer.map_record(MARC::Record.new_from_hash('fields' => [t050], 'leader' => leader)) }

it 'includes a field with data for the classification facet' do
lc_facet = @sample40['lc_facet']
expect(lc_facet).to match_array(['R - Medicine', 'R - Medicine:RA - Public Aspects of Medicine'])
Expand All @@ -1092,6 +1095,10 @@ def fixture_record(fixture_name, indexer: @indexer)
lc_facet = @record_no_call_number['lc_facet']
expect(lc_facet).to be_nil
end

it 'does not index data into the lc_facet field if the call number is invalid' do
expect(record['lc_facet']).to be_nil
end
end

describe 'series 490 dedup, non-filing' do
Expand Down
Loading