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

Index lc_facet field #2547

Merged
merged 4 commits into from
Nov 12, 2024
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
11 changes: 11 additions & 0 deletions marc_to_solr/lib/traject_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,17 @@
end
end

to_field 'lc_facet' do |record, accumulator|
if record['050']
if record['050']['a']
first_letter = record['050']['a'].lstrip.slice(0, 1)
letters = /([[:alpha:]])*/.match(record['050']['a'])[0]
accumulator << Traject::TranslationMap.new("callnumber_map")[first_letter]
accumulator << "#{Traject::TranslationMap.new('callnumber_map')[first_letter]}:#{Traject::TranslationMap.new('callnumber_map')[letters]}"
end
end
rladdusaw marked this conversation as resolved.
Show resolved Hide resolved
end

to_field 'sudoc_facet' do |record, accumulator|
MarcExtractor.cached('086|0 |a').collect_matching_lines(record) do |field, spec, extractor|
letters = /([[:alpha:]])*/.match(extractor.collect_subfields(field, spec).first)[0] if /([[:alpha:]])*/.match?(extractor.collect_subfields(field, spec).first)
Expand Down
15 changes: 15 additions & 0 deletions spec/marc_to_solr/lib/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,21 @@ def fixture_record(fixture_name, indexer: @indexer)
end
end

describe 'lc_facet' do
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'])
end
it 'handles cases where the call number is a single letter' do
lc_facet = @sample44['lc_facet']
expect(lc_facet).to match_array(['Z - Bibliography, Library Science, Information Resources', 'Z - Bibliography, Library Science, Information Resources:Z - Bibliography, Library Science, Information Resources'])
end
it 'handles cases where there is no call number' do
lc_facet = @record_no_call_number['lc_facet']
expect(lc_facet).to be_nil
end
end

describe 'series 490 dedup, non-filing' do
let(:s490) { { "490" => { "ind1" => "", "ind2" => " ", "subfields" => [{ "a" => "Series title" }] } } }
let(:s830) { { "830" => { "ind1" => "", "ind2" => " ", "subfields" => [{ "a" => "Series title." }] } } }
Expand Down