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

(-)a/Koha/SearchEngine/Elasticsearch.pm (-2 / +3 lines)
Lines 823-830 sub marc_records_to_documents { Link Here
823
                if ($field =~ /__sort$/) {
823
                if ($field =~ /__sort$/) {
824
                    # Make sure to keep the sort field length sensible. 255 was chosen as a nice round value.
824
                    # Make sure to keep the sort field length sensible. 255 was chosen as a nice round value.
825
                    $record_document->{$field} = [substr(join(' ', @{$record_document->{$field}}), 0, 255)];
825
                    $record_document->{$field} = [substr(join(' ', @{$record_document->{$field}}), 0, 255)];
826
                    # Strip any initial non-word characters which don't make much sense to sort on
826
                    # Strip any initial non-word characters which don't make much sense to sort on,
827
                    $record_document->{$field} = [map { s/^\W+//u; $_ } @{$record_document->{$field}}];
827
                    # leave as is if contains nothing but non-word characters
828
                    $record_document->{$field} = [map { s/^\W+(?=\w)//u; $_ } @{$record_document->{$field}}];
828
                }
829
                }
829
            }
830
            }
830
        }
831
        }
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t (-3 / +8 lines)
Lines 187-193 subtest 'get_elasticsearch_mappings() tests' => sub { Link Here
187
187
188
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub {
188
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub {
189
189
190
    plan tests => 71;
190
    plan tests => 72;
191
191
192
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
192
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
193
    t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709');
193
    t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709');
Lines 469-475 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
469
        MARC::Field->new('008', '901111s19uu xxk|||| |00| ||eng c'),
469
        MARC::Field->new('008', '901111s19uu xxk|||| |00| ||eng c'),
470
        MARC::Field->new('100', '', '', a => 'Author 2'),
470
        MARC::Field->new('100', '', '', a => 'Author 2'),
471
        # MARC::Field->new('210', '', '', a => 'Title 2'),
471
        # MARC::Field->new('210', '', '', a => 'Title 2'),
472
        # MARC::Field->new('245', '', '', a => 'Title: second record'),
472
        MARC::Field->new('246', '', '', a => '!!!'),
473
        MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', c => '1963-2003'),
473
        MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', c => '1963-2003'),
474
        MARC::Field->new('999', '', '', c => '1234568'),
474
        MARC::Field->new('999', '', '', c => '1234568'),
475
        MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno),
475
        MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno),
Lines 648-653 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
648
    );
648
    );
649
649
650
    # Second record:
650
    # Second record:
651
    
652
    is(
653
        $docs->[1]->{title_sort__sort}[0],
654
        '!!!',
655
        'Second document title_sort should have been left as is as only contains non word characters',
656
    );
651
657
652
    is(scalar @{$docs->[1]->{author}}, 1, 'Second document author field should contain one value');
658
    is(scalar @{$docs->[1]->{author}}, 1, 'Second document author field should contain one value');
653
    is_deeply($docs->[1]->{author}, ['Author 2'], 'Second document author field should be set correctly');
659
    is_deeply($docs->[1]->{author}, ['Author 2'], 'Second document author field should be set correctly');
654
- 

Return to bug 24720