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

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-2 / +2 lines)
Lines 1439-1445 sub _is_safe_to_auto_truncate { Link Here
1439
    # Do not auto truncate fields that should not be auto truncated,
1439
    # Do not auto truncate fields that should not be auto truncated,
1440
    # primarily various types of identifiers, above all record identifiers.
1440
    # primarily various types of identifiers, above all record identifiers.
1441
    # Other search fields that should not be auto truncated can be defined
1441
    # Other search fields that should not be auto truncated can be defined
1442
    # with ESPreventAutoTruncate syspref.
1442
    # with ElasticsearchPreventAutoTruncate syspref.
1443
    my %do_not_autotruncate_fields;
1443
    my %do_not_autotruncate_fields;
1444
    my $cache                          = Koha::Caches->get_instance();
1444
    my $cache                          = Koha::Caches->get_instance();
1445
    my $cache_key                      = 'elasticsearch_search_do_not_autotruncate';
1445
    my $cache_key                      = 'elasticsearch_search_do_not_autotruncate';
Lines 1465-1471 sub _is_safe_to_auto_truncate { Link Here
1465
    # processing of the syspref is done outside cache since the systempreference
1465
    # processing of the syspref is done outside cache since the systempreference
1466
    # can be modified and the modification should be reflected in the
1466
    # can be modified and the modification should be reflected in the
1467
    # $do_not_autotruncate_fields array
1467
    # $do_not_autotruncate_fields array
1468
    my $prevent_autotruncate = C4::Context->preference('ESPreventAutoTruncate');
1468
    my $prevent_autotruncate = C4::Context->preference('ElasticsearchPreventAutoTruncate');
1469
    for my $field ( split( /\s*[,;|]\s*/, $prevent_autotruncate ) ) {
1469
    for my $field ( split( /\s*[,;|]\s*/, $prevent_autotruncate ) ) {
1470
        $do_not_autotruncate_fields{$field} = 1;
1470
        $do_not_autotruncate_fields{$field} = 1;
1471
    }
1471
    }
(-)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 241-246 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
241
('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL),
241
('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL),
242
('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL),
242
('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL),
243
('ElasticsearchMARCFormat', 'base64ISO2709', 'base64ISO2709|ARRAY', 'Elasticsearch MARC format. ISO2709 format is recommended as it is faster and takes less space, whereas array is searchable.', 'Choice'),
243
('ElasticsearchMARCFormat', 'base64ISO2709', 'base64ISO2709|ARRAY', 'Elasticsearch MARC format. ISO2709 format is recommended as it is faster and takes less space, whereas array is searchable.', 'Choice'),
244
('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'),
244
('EmailAddressForPatronRegistrations', '', '', ' If you choose EmailAddressForPatronRegistrations you have to enter a valid email address: ', 'free'),
245
('EmailAddressForPatronRegistrations', '', '', ' If you choose EmailAddressForPatronRegistrations you have to enter a valid email address: ', 'free'),
245
('EmailAddressForSuggestions','','',' If you choose EmailAddressForSuggestions you have to enter a valid email address: ','free'),
246
('EmailAddressForSuggestions','','',' If you choose EmailAddressForSuggestions you have to enter a valid email address: ','free'),
246
('EmailFieldPrecedence','email|emailpro|B_email','','Ordered list of patron email fields to use when AutoEmailPrimaryAddress is set to first valid','multiple'),
247
('EmailFieldPrecedence','email|emailpro|B_email','','Ordered list of patron email fields to use when AutoEmailPrimaryAddress is set to first valid','multiple'),
Lines 267-273 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
267
('ERMProviderEbscoApiKey', '', '', 'API key for EBSCO', 'free'),
268
('ERMProviderEbscoApiKey', '', '', 'API key for EBSCO', 'free'),
268
('ERMProviderEbscoCustomerID', '', '', 'Customer ID for EBSCO', 'free'),
269
('ERMProviderEbscoCustomerID', '', '', 'Customer ID for EBSCO', 'free'),
269
('ERMProviders', 'local', 'local|ebsco', 'Set the providers for the ERM module', 'Choice'),
270
('ERMProviders', 'local', 'local|ebsco', 'Set the providers for the ERM module', 'Choice'),
270
('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'),
271
('ExcludeHolidaysFromMaxPickUpDelay', '0', NULL, 'If ON, reserves max pickup delay takes into accountthe closed days.', 'YesNo'),
271
('ExcludeHolidaysFromMaxPickUpDelay', '0', NULL, 'If ON, reserves max pickup delay takes into accountthe closed days.', 'YesNo'),
272
('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'),
272
('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'),
273
('ExpireReservesAutoFill','0',NULL,'Automatically fill the next hold with a automatically canceled expired waiting hold.','YesNo'),
273
('ExpireReservesAutoFill','0',NULL,'Automatically fill the next hold with a automatically canceled expired waiting hold.','YesNo'),
Lines 891-894 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
891
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
891
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
892
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'),
892
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'),
893
('z3950Status','','','This syspref allows to define custom YAML based rules for marking items unavailable in z3950 results.','Textarea')
893
('z3950Status','','','This syspref allows to define custom YAML based rules for marking items unavailable in z3950 results.','Textarea')
894
;
894
;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref (-1 / +1 lines)
Lines 112-118 Searching: Link Here
112
            - "the option for staff with permission to create/edit custom saved search filters."
112
            - "the option for staff with permission to create/edit custom saved search filters."
113
        -
113
        -
114
            - "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':"
114
            - "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':"
115
            - pref: ESPreventAutoTruncate
115
            - pref: ElasticsearchPreventAutoTruncate
116
              class: long
116
              class: long
117
        -
117
        -
118
            - pref: SearchCancelledAndInvalidISBNandISSN
118
            - pref: SearchCancelledAndInvalidISBNandISSN
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-6 / +5 lines)
Lines 443-450 subtest 'build_query tests' => sub { Link Here
443
        "all quoted strings are unaltered if more than one in query"
443
        "all quoted strings are unaltered if more than one in query"
444
    );
444
    );
445
445
446
    # Reset ESPreventAutoTruncate syspref
446
    # Reset ElasticsearchPreventAutoTruncate syspref
447
    t::lib::Mocks::mock_preference( 'ESPreventAutoTruncate', '' );
447
    t::lib::Mocks::mock_preference( 'ElasticsearchPreventAutoTruncate', '' );
448
448
449
    ( undef, $query ) = $qb->build_query_compat( undef, ['barcode:123456'] );
449
    ( undef, $query ) = $qb->build_query_compat( undef, ['barcode:123456'] );
450
    is(
450
    is(
Lines 481-494 subtest 'build_query tests' => sub { Link Here
481
        "query of specific field including period and quoted is not truncated, field name is converted to lower case"
481
        "query of specific field including period and quoted is not truncated, field name is converted to lower case"
482
    );
482
    );
483
483
484
    # Set ESPreventAutoTruncate syspref
484
    # Set ElasticsearchPreventAutoTruncate syspref
485
    t::lib::Mocks::mock_preference( 'ESPreventAutoTruncate', 'barcode' );
485
    t::lib::Mocks::mock_preference( 'ElasticsearchPreventAutoTruncate', 'barcode' );
486
486
487
    ( undef, $query ) = $qb->build_query_compat( undef, ['barcode:123456'] );
487
    ( undef, $query ) = $qb->build_query_compat( undef, ['barcode:123456'] );
488
    is(
488
    is(
489
        $query->{query}{bool}{must}[0]{query_string}{query},
489
        $query->{query}{bool}{must}[0]{query_string}{query},
490
        '(barcode:123456)',
490
        '(barcode:123456)',
491
        "query of specific field excluded by ESPreventAutoTruncate is not truncated"
491
        "query of specific field excluded by ElasticsearchPreventAutoTruncate is not truncated"
492
    );
492
    );
493
493
494
    ( undef, $query ) = $qb->build_query_compat( undef, ['Local-number:123456'] );
494
    ( undef, $query ) = $qb->build_query_compat( undef, ['Local-number:123456'] );
495
- 

Return to bug 39526