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/Koha/SearchEngine/Elasticsearch.t (-4 / +22 lines)
Lines 118-124 subtest 'get_elasticsearch_mappings() tests' => sub { Link Here
118
118
119
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub {
119
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub {
120
120
121
    plan tests => 58;
121
    plan tests => 59;
122
122
123
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
123
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
124
    t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709');
124
    t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709');
Lines 361-374 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
361
        MARC::Field->new('999', '', '', c => '1234568'),
361
        MARC::Field->new('999', '', '', c => '1234568'),
362
        MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno),
362
        MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno),
363
    );
363
    );
364
    my $records = [$marc_record_1, $marc_record_2];
364
    my $marc_record_3 = MARC::Record->new();
365
    $marc_record_3->leader('     cam  22      a 4500');
366
    $marc_record_3->append_fields(
367
        MARC::Field->new('008', '901111s19uu xxk|||| |00| ||eng c'),
368
        MARC::Field->new('100', '', '', a => 'Author 2'),
369
        # MARC::Field->new('210', '', '', a => 'Title 3'),
370
        # MARC::Field->new('245', '', '', a => 'Title: third record'),
371
        MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', c => ' 89 '),
372
        MARC::Field->new('999', '', '', c => '1234568'),
373
        MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno),
374
    );
375
    my $records = [$marc_record_1, $marc_record_2, $marc_record_3];
365
376
366
    $see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first
377
    $see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first
367
378
368
    my $docs = $see->marc_records_to_documents($records);
379
    my $docs = $see->marc_records_to_documents($records);
369
380
370
    # First record:
381
    # First record:
371
    is(scalar @{$docs}, 2, 'Two records converted to documents');
382
    is(scalar @{$docs}, 3, 'Two records converted to documents');
372
383
373
    is_deeply($docs->[0]->{control_number}, ['123'], 'First record control number should be set correctly');
384
    is_deeply($docs->[0]->{control_number}, ['123'], 'First record control number should be set correctly');
374
385
Lines 527-532 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
527
      'Second document date-of-publication field should be set correctly'
538
      'Second document date-of-publication field should be set correctly'
528
    );
539
    );
529
540
541
    # Third record:
542
543
    is_deeply(
544
      $docs->[2]->{'copydate'},
545
      ['0890'],
546
      'Third document copydate field should be set correctly'
547
    );
548
530
    # Mappings marc_type:
549
    # Mappings marc_type:
531
550
532
    ok(!(defined $docs->[0]->{unimarc_title}), "No mapping when marc_type doesn't match marc flavour");
551
    ok(!(defined $docs->[0]->{unimarc_title}), "No mapping when marc_type doesn't match marc flavour");
533
- 

Return to bug 24807