Skip to content

Commit

Permalink
Merge pull request #1457 from sul-dlss/index-best_author_title_search
Browse files Browse the repository at this point in the history
Add indexing for the best_author_title_search field
  • Loading branch information
cbeer authored Jun 15, 2024
2 parents 5f5f8e2 + b7bfbfc commit 51c121e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/traject/config/folio_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ def items(record, context)
accumulator << [onexx, twoxx].compact.reject(&:empty?).map(&:strip).join(' ') if onexx && twoxx
end

to_field 'best_author_title_search' do |_record, accumulator, context|
accumulator << context.output_hash['author_title_search'].first if context.output_hash['author_title_search']
end

# # Author Search Fields
# # IFF relevancy of author search needs improvement, unstemmed flavors for author search
# # (keep using stemmed version for everything search to match stemmed query)
Expand Down
14 changes: 14 additions & 0 deletions spec/lib/traject/config/author_title_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@
let(:field) { 'author_title_search' }
subject(:results) { records.map { |rec| indexer.map_record(marc_to_folio(rec)) }.to_a }

describe 'best_author_title_search' do
let(:field) { 'best_author_title_search' }

it 'maps the right data' do
expect(select_by_id('100240')[field]).to eq ['100a 100b 100c 100d 100f 100g 100j 100k 100l 100n 100p 100q 100t 100u 240a 240d 240f 240g 240h 240k 240l 240m 240n 240o 240p 240r 240s']
expect(select_by_id('110240')[field]).to eq ['110a 110b 110c 110d 110f 110g 110k 110l 110n 110p 110t 110u 240a 240d 240f 240g 240h 240k 240l 240m 240n 240o 240p 240r 240s']
expect(select_by_id('111240')[field]).to eq ['111a 111c 111d 111e 111f 111g 111j 111k 111l 111n 111p 111q 111t 111u 240a 240d 240f 240g 240h 240k 240l 240m 240n 240o 240p 240r 240s']

expect(select_by_id('100no240')[field]).to eq ['100a 100b 100c 100d 100f 100g 100j 100k 100l 100n 100p 100q 100t 100u 245a']
expect(select_by_id('110no240')[field]).to eq ['110a 110b 110c 110d 110f 110g 110k 110l 110n 110p 110t 110u 245a']
expect(select_by_id('111no240')[field]).to eq ['111a 111c 111d 111e 111f 111g 111j 111k 111l 111n 111p 111q 111t 111u 245a']
end
end

# rubocop:disable Layout/LineLength
describe 'maps search field values from 100, 110, 111 with data from the 240 or 245' do
it 'maps the right data' do
Expand Down

0 comments on commit 51c121e

Please sign in to comment.