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

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-3 / +3 lines)
Lines 441-452 sub build_authorities_query { Link Here
441
            # Given that field data is "The quick brown fox"
441
            # Given that field data is "The quick brown fox"
442
            # a search containing any of the words will match, regardless
442
            # a search containing any of the words will match, regardless
443
            # of order.
443
            # of order.
444
            my $truncate = C4::Context->preference("QueryAutoTruncate") || 0;
444
445
445
            my @tokens = $self->_split_query( $val );
446
            my @tokens = $self->_split_query( $val );
446
            foreach my $token ( @tokens ) {
447
            foreach my $token ( @tokens ) {
447
                $token = $self->_truncate_terms(
448
                $token = $self->clean_search_term( $token );
448
                    $self->clean_search_term( $token )
449
                $token = $self->_truncate_terms( $token ) if $truncate;
449
                );
450
            }
450
            }
451
            my $query = $self->_join_queries( @tokens );
451
            my $query = $self->_join_queries( @tokens );
452
            my $query_string = {
452
            my $query_string = {
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-2 / +24 lines)
Lines 22-28 use Test::Exception; Link Here
22
use Test::Warn;
22
use Test::Warn;
23
use t::lib::Mocks;
23
use t::lib::Mocks;
24
use t::lib::TestBuilder;
24
use t::lib::TestBuilder;
25
use Test::More tests => 7;
25
use Test::More tests => 8;
26
26
27
use List::Util qw( all );
27
use List::Util qw( all );
28
28
Lines 101-110 $se->mock( 'get_elasticsearch_mappings', sub { Link Here
101
    return $all_mappings{$self->index};
101
    return $all_mappings{$self->index};
102
});
102
});
103
103
104
subtest 'build_authorities_query_compat() no query truncate tests' => sub {
105
106
    plan tests => 9;
107
108
    t::lib::Mocks::mock_preference( 'QueryAutoTruncate', '' );
109
110
    my $qb;
111
112
    ok(
113
        $qb = Koha::SearchEngine::Elasticsearch::QueryBuilder->new({ 'index' => 'authorities' }),
114
        'Creating new query builder object for authorities'
115
    );
116
117
    my $koha_to_index_name = $Koha::SearchEngine::Elasticsearch::QueryBuilder::koha_to_index_name;
118
    my $search_term = 'a';
119
    foreach my $koha_name ( keys %{ $koha_to_index_name } ) {
120
        my $query = $qb->build_authorities_query_compat( [ $koha_name ],  undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', 'asc' );
121
        is( $query->{query}->{bool}->{must}[0]->{query_string}->{query}, 'a');
122
    }
123
};
124
104
subtest 'build_authorities_query_compat() tests' => sub {
125
subtest 'build_authorities_query_compat() tests' => sub {
105
126
106
    plan tests => 65;
127
    plan tests => 65;
107
128
129
    t::lib::Mocks::mock_preference( 'QueryAutoTruncate', 1 );
130
108
    my $qb;
131
    my $qb;
109
132
110
    ok(
133
    ok(
111
- 

Return to bug 30817