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

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-1 / +1 lines)
Lines 283-289 sub build_query_compat { Link Here
283
        my @sort_params  = $self->_convert_sort_fields(@$sort_by);
283
        my @sort_params  = $self->_convert_sort_fields(@$sort_by);
284
        my @index_params = $self->_convert_index_fields(@$indexes);
284
        my @index_params = $self->_convert_index_fields(@$indexes);
285
        my $field_match_boost_query =
285
        my $field_match_boost_query =
286
            C4::Context->preference('ESBoostFieldMatch')
286
            C4::Context->preference('ElasticsearchBoostFieldMatch')
287
            ? $self->_build_field_match_boost_query( { operands => $operands, indexes => \@index_params } )
287
            ? $self->_build_field_match_boost_query( { operands => $operands, indexes => \@index_params } )
288
            : [];
288
            : [];
289
        $limits = $self->_fix_limit_special_cases($orig_limits);
289
        $limits = $self->_fix_limit_special_cases($orig_limits);
(-)a/installer/data/mysql/atomicupdate/bug38694.pl (-3 / +3 lines)
Lines 3-9 use Koha::Installer::Output qw(say_warning say_success say_info); Link Here
3
3
4
return {
4
return {
5
    bug_number  => "38694",
5
    bug_number  => "38694",
6
    description => "Add ESBoostFieldMatch system preference",
6
    description => "Add ElasticsearchBoostFieldMatch system preference",
7
    up          => sub {
7
    up          => sub {
8
        my ($args) = @_;
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
Lines 12-21 return { Link Here
12
        $dbh->do(
12
        $dbh->do(
13
            q{
13
            q{
14
           INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
14
           INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
15
           ('ESBoostFieldMatch', '0', NULL, 'Add a "match" query to es when searching, will follow indexes chosen in advanced search, or use title-cover for generic keyword or title index search', 'YesNo')
15
           ('ElasticsearchBoostFieldMatch', '0', NULL, 'Add a "match" query to es when searching, will follow indexes chosen in advanced search, or use title-cover for generic keyword or title index search', 'YesNo')
16
       }
16
       }
17
        );
17
        );
18
18
19
        say_success( $out, "Added new system preference 'ESBoostFieldMatch'" );
19
        say_success( $out, "Added new system preference 'ElasticsearchBoostFieldMatch'" );
20
    },
20
    },
21
};
21
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 / +1 lines)
Lines 231-236 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
231
('EDIFACT','0',NULL,'Enables EDIFACT acquisitions functions','YesNo'),
231
('EDIFACT','0',NULL,'Enables EDIFACT acquisitions functions','YesNo'),
232
('EdifactInvoiceImport', 'automatic', 'automatic|manual', "If on, don't auto-import EDI invoices, just keep them in the database with the status 'new'", 'Choice'),
232
('EdifactInvoiceImport', 'automatic', 'automatic|manual', "If on, don't auto-import EDI invoices, just keep them in the database with the status 'new'", 'Choice'),
233
('EdifactLSQ', 'location', 'location|ccode', 'Map EDI sequence code (GIR+LSQ) to Koha Item field', 'Choice'),
233
('EdifactLSQ', 'location', 'location|ccode', 'Map EDI sequence code (GIR+LSQ) to Koha Item field', 'Choice'),
234
('ElasticsearchBoostFieldMatch', '0', NULL, 'Add a "match" query to es when searching, will follow indexes chosen in advanced search, or use title-cover for generic keyword or title index search', 'YesNo'),
234
('ElasticsearchCrossFields', '1', '', 'Enable "cross_fields" option for searches using Elastic search.', 'YesNo'),
235
('ElasticsearchCrossFields', '1', '', 'Enable "cross_fields" option for searches using Elastic search.', 'YesNo'),
235
('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL),
236
('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL),
236
('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL),
237
('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL),
Lines 260-266 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
260
('ERMProviderEbscoApiKey', '', '', 'API key for EBSCO', 'free'),
261
('ERMProviderEbscoApiKey', '', '', 'API key for EBSCO', 'free'),
261
('ERMProviderEbscoCustomerID', '', '', 'Customer ID for EBSCO', 'free'),
262
('ERMProviderEbscoCustomerID', '', '', 'Customer ID for EBSCO', 'free'),
262
('ERMProviders', 'local', 'local|ebsco', 'Set the providers for the ERM module', 'Choice'),
263
('ERMProviders', 'local', 'local|ebsco', 'Set the providers for the ERM module', 'Choice'),
263
('ESBoostFieldMatch', '0', NULL, 'Add a "match" query to es when searching, will follow indexes chosen in advanced search, or use title-cover for generic keyword or title index search', 'YesNo'),
264
('ESPreventAutoTruncate', 'barcode|control-number|control-number-identifier|date-of-acquisition|date-of-publication|date-time-last-modified|identifier-standard|isbn|issn|itype|lc-card-number|number-local-acquisition|other-control-number|record-control-number', NULL, 'List of searchfields (separated by | or ,) that should not be autotruncated by Elasticsearch even if QueryAutoTruncate is set to Yes', 'free'),
264
('ESPreventAutoTruncate', 'barcode|control-number|control-number-identifier|date-of-acquisition|date-of-publication|date-time-last-modified|identifier-standard|isbn|issn|itype|lc-card-number|number-local-acquisition|other-control-number|record-control-number', NULL, 'List of searchfields (separated by | or ,) that should not be autotruncated by Elasticsearch even if QueryAutoTruncate is set to Yes', 'free'),
265
('ExcludeHolidaysFromMaxPickUpDelay', '0', NULL, 'If ON, reserves max pickup delay takes into accountthe closed days.', 'YesNo'),
265
('ExcludeHolidaysFromMaxPickUpDelay', '0', NULL, 'If ON, reserves max pickup delay takes into accountthe closed days.', 'YesNo'),
266
('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'),
266
('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref (-1 / +1 lines)
Lines 96-102 Searching: Link Here
96
            - "the cross_fields option for Elasticsearch searches, supported in Elasticsearch 6.X and above."
96
            - "the cross_fields option for Elasticsearch searches, supported in Elasticsearch 6.X and above."
97
            - See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#type-cross-fields">Elasticsearch cross_fields documentation</a>.
97
            - See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#type-cross-fields">Elasticsearch cross_fields documentation</a>.
98
        -
98
        -
99
            - pref: ESBoostFieldMatch
99
            - pref: ElasticsearchBoostFieldMatch
100
              default: 0
100
              default: 0
101
              choices:
101
              choices:
102
                  1: Enable
102
                  1: Enable
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-4 / +3 lines)
Lines 1234-1241 subtest "_build_field_match_boost_query() tests" => sub { Link Here
1234
        'Title is not converted to title-cover'
1234
        'Title is not converted to title-cover'
1235
    );
1235
    );
1236
1236
1237
    t::lib::Mocks::mock_preference( 'ESBoostFieldMatch', '0' );
1237
    t::lib::Mocks::mock_preference( 'ElasticsearchBoostFieldMatch', '0' );
1238
    t::lib::Mocks::mock_preference( 'QueryAutoTruncate', '1' );
1238
    t::lib::Mocks::mock_preference( 'QueryAutoTruncate',            '1' );
1239
    my ( undef, $query ) = $qb->build_query_compat( ['AND'], [ 'donald duck', 'disney' ], [ 'title', 'author' ] );
1239
    my ( undef, $query ) = $qb->build_query_compat( ['AND'], [ 'donald duck', 'disney' ], [ 'title', 'author' ] );
1240
    is(
1240
    is(
1241
        $query->{query}{bool}{must}[0]{query_string}{query},
1241
        $query->{query}{bool}{must}[0]{query_string}{query},
Lines 1248-1254 subtest "_build_field_match_boost_query() tests" => sub { Link Here
1248
        'No should query added for boosting'
1248
        'No should query added for boosting'
1249
    );
1249
    );
1250
1250
1251
    t::lib::Mocks::mock_preference( 'ESBoostFieldMatch', '1' );
1251
    t::lib::Mocks::mock_preference( 'ElasticsearchBoostFieldMatch', '1' );
1252
    ( undef, $query ) = $qb->build_query_compat( ['AND'], [ 'donald duck', 'disney' ], [ 'title', 'author' ] );
1252
    ( undef, $query ) = $qb->build_query_compat( ['AND'], [ 'donald duck', 'disney' ], [ 'title', 'author' ] );
1253
    is_deeply(
1253
    is_deeply(
1254
        $query->{query}{bool}{should},
1254
        $query->{query}{bool}{should},
1255
- 

Return to bug 38694