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

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-2 / +2 lines)
Lines 1402-1408 sub _is_safe_to_auto_truncate { Link Here
1402
    # Do not auto truncate fields that should not be auto truncated,
1402
    # Do not auto truncate fields that should not be auto truncated,
1403
    # primarily various types of identifiers, above all record identifiers.
1403
    # primarily various types of identifiers, above all record identifiers.
1404
    # Other search fields that should not be auto truncated can be defined
1404
    # Other search fields that should not be auto truncated can be defined
1405
    # with ESPreventAutoTruncate syspref.
1405
    # with ElasticsearchPreventAutoTruncate syspref.
1406
    my %do_not_autotruncate_fields;
1406
    my %do_not_autotruncate_fields;
1407
    my $cache                          = Koha::Caches->get_instance();
1407
    my $cache                          = Koha::Caches->get_instance();
1408
    my $cache_key                      = 'elasticsearch_search_do_not_autotruncate';
1408
    my $cache_key                      = 'elasticsearch_search_do_not_autotruncate';
Lines 1428-1434 sub _is_safe_to_auto_truncate { Link Here
1428
    # processing of the syspref is done outside cache since the systempreference
1428
    # processing of the syspref is done outside cache since the systempreference
1429
    # can be modified and the modification should be reflected in the
1429
    # can be modified and the modification should be reflected in the
1430
    # $do_not_autotruncate_fields array
1430
    # $do_not_autotruncate_fields array
1431
    my $prevent_autotruncate = C4::Context->preference('ESPreventAutoTruncate');
1431
    my $prevent_autotruncate = C4::Context->preference('ElasticsearchPreventAutoTruncate');
1432
    for my $field ( split( /\s*[,;|]\s*/, $prevent_autotruncate ) ) {
1432
    for my $field ( split( /\s*[,;|]\s*/, $prevent_autotruncate ) ) {
1433
        $do_not_autotruncate_fields{$field} = 1;
1433
        $do_not_autotruncate_fields{$field} = 1;
1434
    }
1434
    }
(-)a/installer/data/mysql/atomicupdate/bug_39526_unify_syspref_variable_names_for_elasticsearch.pl (+18 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_success say_info);
3
4
return {
5
    bug_number  => "39526",
6
    description => "Unify system preference variable names for Elasticsearch",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        # Do you stuffs here
12
        $dbh->do(
13
            q{update systempreferences set variable = REGEXP_REPLACE(variable, '^ES', 'Elasticsearch') where variable like 'ES%'}
14
        );
15
16
        say $out "Renamed system preference 'ES..' to 'Elasticsearch..'";
17
    },
18
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-2 / +2 lines)
Lines 236-241 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
236
('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL),
236
('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL),
237
('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL),
237
('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL),
238
('ElasticsearchMARCFormat', 'base64ISO2709', 'base64ISO2709|ARRAY', 'Elasticsearch MARC format. ISO2709 format is recommended as it is faster and takes less space, whereas array is searchable.', 'Choice'),
238
('ElasticsearchMARCFormat', 'base64ISO2709', 'base64ISO2709|ARRAY', 'Elasticsearch MARC format. ISO2709 format is recommended as it is faster and takes less space, whereas array is searchable.', 'Choice'),
239
('ElasticsearchPreventAutoTruncate', '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'),
239
('EmailAddressForPatronRegistrations', '', '', ' If you choose EmailAddressForPatronRegistrations you have to enter a valid email address: ', 'free'),
240
('EmailAddressForPatronRegistrations', '', '', ' If you choose EmailAddressForPatronRegistrations you have to enter a valid email address: ', 'free'),
240
('EmailAddressForSuggestions','','',' If you choose EmailAddressForSuggestions you have to enter a valid email address: ','free'),
241
('EmailAddressForSuggestions','','',' If you choose EmailAddressForSuggestions you have to enter a valid email address: ','free'),
241
('EmailFieldPrecedence','email|emailpro|B_email','','Ordered list of patron email fields to use when AutoEmailPrimaryAddress is set to first valid','multiple'),
242
('EmailFieldPrecedence','email|emailpro|B_email','','Ordered list of patron email fields to use when AutoEmailPrimaryAddress is set to first valid','multiple'),
Lines 261-267 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
261
('ERMProviderEbscoApiKey', '', '', 'API key for EBSCO', 'free'),
262
('ERMProviderEbscoApiKey', '', '', 'API key for EBSCO', 'free'),
262
('ERMProviderEbscoCustomerID', '', '', 'Customer ID for EBSCO', 'free'),
263
('ERMProviderEbscoCustomerID', '', '', 'Customer ID for EBSCO', 'free'),
263
('ERMProviders', 'local', 'local|ebsco', 'Set the providers for the ERM module', 'Choice'),
264
('ERMProviders', 'local', 'local|ebsco', 'Set the providers for the ERM module', 'Choice'),
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'),
267
('ExpireReservesAutoFill','0',NULL,'Automatically fill the next hold with a automatically canceled expired waiting hold.','YesNo'),
267
('ExpireReservesAutoFill','0',NULL,'Automatically fill the next hold with a automatically canceled expired waiting hold.','YesNo'),
Lines 879-882 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
879
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
879
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
880
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'),
880
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'),
881
('z3950Status','','','This syspref allows to define custom YAML based rules for marking items unavailable in z3950 results.','Textarea')
881
('z3950Status','','','This syspref allows to define custom YAML based rules for marking items unavailable in z3950 results.','Textarea')
882
;
882
;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref (-1 / +1 lines)
Lines 104-110 Searching: Link Here
104
            - "the option for staff with permission to create/edit custom saved search filters."
104
            - "the option for staff with permission to create/edit custom saved search filters."
105
        -
105
        -
106
            - "List of search fields (separated by | or ,) that should not be autotruncated by Elasticsearch even if <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=QueryAutoTruncate'>QueryAutoTruncate</a> is set to 'Yes':"
106
            - "List of search fields (separated by | or ,) that should not be autotruncated by Elasticsearch even if <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=QueryAutoTruncate'>QueryAutoTruncate</a> is set to 'Yes':"
107
            - pref: ESPreventAutoTruncate
107
            - pref: ElasticsearchPreventAutoTruncate
108
              class: long
108
              class: long
109
        -
109
        -
110
            - pref: SearchCancelledAndInvalidISBNandISSN
110
            - pref: SearchCancelledAndInvalidISBNandISSN
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-6 / +5 lines)
Lines 419-426 subtest 'build_query tests' => sub { Link Here
419
        "all quoted strings are unaltered if more than one in query"
419
        "all quoted strings are unaltered if more than one in query"
420
    );
420
    );
421
421
422
    # Reset ESPreventAutoTruncate syspref
422
    # Reset ElasticsearchPreventAutoTruncate syspref
423
    t::lib::Mocks::mock_preference( 'ESPreventAutoTruncate', '' );
423
    t::lib::Mocks::mock_preference( 'ElasticsearchPreventAutoTruncate', '' );
424
424
425
    ( undef, $query ) = $qb->build_query_compat( undef, ['barcode:123456'] );
425
    ( undef, $query ) = $qb->build_query_compat( undef, ['barcode:123456'] );
426
    is(
426
    is(
Lines 457-470 subtest 'build_query tests' => sub { Link Here
457
        "query of specific field including period and quoted is not truncated, field name is converted to lower case"
457
        "query of specific field including period and quoted is not truncated, field name is converted to lower case"
458
    );
458
    );
459
459
460
    # Set ESPreventAutoTruncate syspref
460
    # Set ElasticsearchPreventAutoTruncate syspref
461
    t::lib::Mocks::mock_preference( 'ESPreventAutoTruncate', 'barcode' );
461
    t::lib::Mocks::mock_preference( 'ElasticsearchPreventAutoTruncate', 'barcode' );
462
462
463
    ( undef, $query ) = $qb->build_query_compat( undef, ['barcode:123456'] );
463
    ( undef, $query ) = $qb->build_query_compat( undef, ['barcode:123456'] );
464
    is(
464
    is(
465
        $query->{query}{query_string}{query},
465
        $query->{query}{query_string}{query},
466
        '(barcode:123456)',
466
        '(barcode:123456)',
467
        "query of specific field excluded by ESPreventAutoTruncate is not truncated"
467
        "query of specific field excluded by ElasticsearchPreventAutoTruncate is not truncated"
468
    );
468
    );
469
469
470
    ( undef, $query ) = $qb->build_query_compat( undef, ['Local-number:123456'] );
470
    ( undef, $query ) = $qb->build_query_compat( undef, ['Local-number:123456'] );
471
- 

Return to bug 39526