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

(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-3 / +16 lines)
Lines 1205-1212 subtest "_sort_field() tests" => sub { Link Here
1205
};
1205
};
1206
1206
1207
subtest "_build_field_match_boost_query() tests" => sub {
1207
subtest "_build_field_match_boost_query() tests" => sub {
1208
    plan tests => 10;
1208
    plan tests => 11;
1209
1209
1210
    t::lib::Mocks::mock_preference( 'ElasticsearchBoostFieldMatchAmount', '0' );
1210
    my $qb;
1211
    my $qb;
1211
1212
1212
    ok(
1213
    ok(
Lines 1269-1274 subtest "_build_field_match_boost_query() tests" => sub { Link Here
1269
        'Title is not converted to title-cover'
1270
        'Title is not converted to title-cover'
1270
    );
1271
    );
1271
1272
1273
    t::lib::Mocks::mock_preference( 'ElasticsearchBoostFieldMatchAmount', '10' );
1274
    $field_match_boost_query = $qb->_build_field_match_boost_query( { indexes => \@indexes, operands => \@operands } );
1275
    is_deeply(
1276
        $field_match_boost_query,
1277
        [
1278
            { match => { 'title-cover' => { boost => 10, query => 'turkey' } } },
1279
            { match => { 'subject'     => { boost => 10, query => 'gravy' } } },
1280
            { match => { 'title-cover' => { boost => 10, query => 'mashed' } } },
1281
        ],
1282
        'Boost is added to fields as expected only when pref has a value'
1283
    );
1284
1272
    t::lib::Mocks::mock_preference( 'ElasticsearchBoostFieldMatch', '0' );
1285
    t::lib::Mocks::mock_preference( 'ElasticsearchBoostFieldMatch', '0' );
1273
    t::lib::Mocks::mock_preference( 'QueryAutoTruncate',            '1' );
1286
    t::lib::Mocks::mock_preference( 'QueryAutoTruncate',            '1' );
1274
    my ( undef, $query ) = $qb->build_query_compat( ['AND'], [ 'donald duck', 'disney' ], [ 'title', 'author' ] );
1287
    my ( undef, $query ) = $qb->build_query_compat( ['AND'], [ 'donald duck', 'disney' ], [ 'title', 'author' ] );
Lines 1283-1289 subtest "_build_field_match_boost_query() tests" => sub { Link Here
1283
        'No should query added for boosting'
1296
        'No should query added for boosting'
1284
    );
1297
    );
1285
1298
1286
    t::lib::Mocks::mock_preference( 'ElasticsearchBoostFieldMatch', '1' );
1299
    t::lib::Mocks::mock_preference( 'ElasticsearchBoostFieldMatch',       '1' );
1300
    t::lib::Mocks::mock_preference( 'ElasticsearchBoostFieldMatchAmount', '0' );
1287
    ( undef, $query ) = $qb->build_query_compat( ['AND'], [ 'donald duck', 'disney' ], [ 'title', 'author' ] );
1301
    ( undef, $query ) = $qb->build_query_compat( ['AND'], [ 'donald duck', 'disney' ], [ 'title', 'author' ] );
1288
    is_deeply(
1302
    is_deeply(
1289
        $query->{query}{bool}{should},
1303
        $query->{query}{bool}{should},
1290
- 

Return to bug 40853