|
Lines 186-192
subtest 'get_elasticsearch_mappings() tests' => sub {
Link Here
|
| 186 |
|
186 |
|
| 187 |
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub { |
187 |
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub { |
| 188 |
|
188 |
|
| 189 |
plan tests => 69; |
189 |
plan tests => 70; |
| 190 |
|
190 |
|
| 191 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
191 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
| 192 |
t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709'); |
192 |
t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709'); |
|
Lines 393-398
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
| 393 |
marc_type => 'marc21', |
393 |
marc_type => 'marc21', |
| 394 |
marc_field => '650(avxyz)', |
394 |
marc_field => '650(avxyz)', |
| 395 |
}, |
395 |
}, |
|
|
396 |
{ |
| 397 |
name => 'note', |
| 398 |
type => 'string', |
| 399 |
facet => 0, |
| 400 |
suggestible => 0, |
| 401 |
searchable => 1, |
| 402 |
sort => 1, |
| 403 |
marc_type => 'marc21', |
| 404 |
marc_field => '522a', |
| 405 |
}, |
| 396 |
); |
406 |
); |
| 397 |
|
407 |
|
| 398 |
my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch'); |
408 |
my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch'); |
|
Lines 755-769
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
| 755 |
my $marc_record_with_large_field = MARC::Record->new(); |
765 |
my $marc_record_with_large_field = MARC::Record->new(); |
| 756 |
$marc_record_with_large_field->leader(' cam 22 a 4500'); |
766 |
$marc_record_with_large_field->leader(' cam 22 a 4500'); |
| 757 |
|
767 |
|
|
|
768 |
my $xs = 'X' x 8191; |
| 769 |
my $ys = 'Y' x 8191; |
| 770 |
my $zs = 'Z' x 8191 . 'W'; # one extra character so it needs splitting |
| 771 |
|
| 758 |
$marc_record_with_large_field->append_fields( |
772 |
$marc_record_with_large_field->append_fields( |
| 759 |
MARC::Field->new( '100', '', '', a => 'Author 1' ), |
773 |
MARC::Field->new( '100', '', '', a => 'Author 1' ), |
| 760 |
MARC::Field->new( '245', '', '', a => 'Title:', b => 'record with large field' ), |
774 |
MARC::Field->new( '245', '', '', a => 'Title:', b => 'record with large field' ), |
| 761 |
MARC::Field->new( '500', '', '', a => 'X' x 15000 ), |
775 |
MARC::Field->new( '500', '', '', a => 'X' x 15000 ), |
|
|
776 |
MARC::Field->new( '522', '', '', a => "$xs $ys $zs" ), |
| 762 |
MARC::Field->new( '999', '', '', c => '1234567' ), |
777 |
MARC::Field->new( '999', '', '', c => '1234567' ), |
| 763 |
); |
778 |
); |
| 764 |
|
779 |
|
| 765 |
$docs = $see->marc_records_to_documents( [$marc_record_with_large_field] ); |
780 |
$docs = $see->marc_records_to_documents( [$marc_record_with_large_field] ); |
| 766 |
|
781 |
|
|
|
782 |
subtest '_process_mappings() split tests' => sub { |
| 783 |
|
| 784 |
plan tests => 4; |
| 785 |
|
| 786 |
my $note_indexes = $docs->[0]->{note}; |
| 787 |
|
| 788 |
is( $note_indexes->[0], $xs, 'First chunk split using the space' ); |
| 789 |
is( $note_indexes->[1], $ys, 'Second chunk split using the space' ); |
| 790 |
is( $note_indexes->[2], substr( $zs, 0, 8191 ), 'Third chunk is forced to split' ); |
| 791 |
is( $note_indexes->[3], substr( $zs, 8191, 1 ), 'Fourth chunk is just the remaining char' ); |
| 792 |
}; |
| 793 |
|
| 767 |
is( $docs->[0]->{marc_format}, 'MARCXML', 'For record with large field marc_format should be set correctly' ); |
794 |
is( $docs->[0]->{marc_format}, 'MARCXML', 'For record with large field marc_format should be set correctly' ); |
| 768 |
|
795 |
|
| 769 |
$decoded_marc_record = $see->decode_record_from_result( $docs->[0] ); |
796 |
$decoded_marc_record = $see->decode_record_from_result( $docs->[0] ); |
| 770 |
- |
|
|