View | Details | Raw Unified | Return to bug 24807
Collapse All | Expand All

(-)a/Koha/SearchEngine/Elasticsearch.pm (-1 / +1 lines)
Lines 909-915 sub _field_mappings { Link Here
909
        push @{$default_options->{value_callbacks}}, sub {
909
        push @{$default_options->{value_callbacks}}, sub {
910
            my ($value) = @_;
910
            my ($value) = @_;
911
            # Replace "u" with "0" for sorting
911
            # Replace "u" with "0" for sorting
912
            return map { s/[u]/0/gr } ( $value =~ /[0-9u]{4}/g );
912
            return map { s/[u\s]/0/gr } ( $value =~ /[0-9u\s]{4}/g );
913
        };
913
        };
914
    }
914
    }
915
915
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t (-4 / +23 lines)
Lines 132-138 subtest 'get_elasticsearch_mappings() tests' => sub { Link Here
132
132
133
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub {
133
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub {
134
134
135
    plan tests => 58;
135
    plan tests => 59;
136
136
137
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
137
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
138
    t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709');
138
    t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709');
Lines 375-388 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
375
        MARC::Field->new('999', '', '', c => '1234568'),
375
        MARC::Field->new('999', '', '', c => '1234568'),
376
        MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno),
376
        MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno),
377
    );
377
    );
378
    my $records = [ $marc_record_1, $marc_record_2 ];
378
379
    my $marc_record_3 = MARC::Record->new();
380
    $marc_record_3->leader('     cam  22      a 4500');
381
    $marc_record_3->append_fields(
382
        MARC::Field->new('008', '901111s19uu xxk|||| |00| ||eng c'),
383
        MARC::Field->new('100', '', '', a => 'Author 2'),
384
        # MARC::Field->new('210', '', '', a => 'Title 3'),
385
        # MARC::Field->new('245', '', '', a => 'Title: third record'),
386
        MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', c => ' 89 '),
387
        MARC::Field->new('999', '', '', c => '1234568'),
388
        MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno),
389
    );
390
    my $records = [$marc_record_1, $marc_record_2, $marc_record_3];
379
391
380
    $see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first
392
    $see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first
381
393
382
    my $docs = $see->marc_records_to_documents($records);
394
    my $docs = $see->marc_records_to_documents($records);
383
395
384
    # First record:
396
    # First record:
385
    is(scalar @{$docs}, 2, 'Two records converted to documents');
397
    is(scalar @{$docs}, 3, 'Two records converted to documents');
386
398
387
    is_deeply($docs->[0]->{control_number}, ['123'], 'First record control number should be set correctly');
399
    is_deeply($docs->[0]->{control_number}, ['123'], 'First record control number should be set correctly');
388
400
Lines 541-546 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
541
      'Second document date-of-publication field should be set correctly'
553
      'Second document date-of-publication field should be set correctly'
542
    );
554
    );
543
555
556
    # Third record:
557
558
    is_deeply(
559
      $docs->[2]->{'copydate'},
560
      ['0890'],
561
      'Third document copydate field should be set correctly'
562
    );
563
544
    # Mappings marc_type:
564
    # Mappings marc_type:
545
565
546
    ok(!(defined $docs->[0]->{unimarc_title}), "No mapping when marc_type doesn't match marc flavour");
566
    ok(!(defined $docs->[0]->{unimarc_title}), "No mapping when marc_type doesn't match marc flavour");
547
- 

Return to bug 24807