From 1cc62117b65770df09e634cb0978c8532fc7562e Mon Sep 17 00:00:00 2001 From: Max Kadel Date: Fri, 7 Feb 2025 12:26:32 -0500 Subject: [PATCH 1/2] Do not index : for invalid call numbers --- marc_to_solr/lib/traject_config.rb | 6 +++++- spec/marc_to_solr/lib/config_spec.rb | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/marc_to_solr/lib/traject_config.rb b/marc_to_solr/lib/traject_config.rb index 6ab73d2a..a725ae88 100644 --- a/marc_to_solr/lib/traject_config.rb +++ b/marc_to_solr/lib/traject_config.rb @@ -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 diff --git a/spec/marc_to_solr/lib/config_spec.rb b/spec/marc_to_solr/lib/config_spec.rb index 06529a8a..2a65b540 100644 --- a/spec/marc_to_solr/lib/config_spec.rb +++ b/spec/marc_to_solr/lib/config_spec.rb @@ -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']) @@ -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 'handles cases where the call number is invalid' do + expect(record['lc_facet']).to be_nil + end end describe 'series 490 dedup, non-filing' do From 71d8a81726b6222a5cce9ee09ad6e2f12601c903 Mon Sep 17 00:00:00 2001 From: Max Kadel Date: Mon, 10 Feb 2025 08:27:02 -0500 Subject: [PATCH 2/2] Update spec/marc_to_solr/lib/config_spec.rb Co-authored-by: Jane Sandberg --- spec/marc_to_solr/lib/config_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/marc_to_solr/lib/config_spec.rb b/spec/marc_to_solr/lib/config_spec.rb index 2a65b540..61ca638c 100644 --- a/spec/marc_to_solr/lib/config_spec.rb +++ b/spec/marc_to_solr/lib/config_spec.rb @@ -1096,7 +1096,7 @@ def fixture_record(fixture_name, indexer: @indexer) expect(lc_facet).to be_nil end - it 'handles cases where the call number is invalid' do + 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