From 210732f1dd85bd5a89a4a607515d80bbf95c47ad Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Wed, 4 Mar 2026 15:31:24 +0000 Subject: [PATCH] Bug 28884: Add 'ElasticsearchEscapeCharacters' and 'OpacElasticsearchEscapeCharacters' system preferences --- .../data/mysql/atomicupdate/bug_28884.pl | 25 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 2 ++ .../modules/admin/preferences/searching.pref | 8 ++++++ 3 files changed, 35 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_28884.pl diff --git a/installer/data/mysql/atomicupdate/bug_28884.pl b/installer/data/mysql/atomicupdate/bug_28884.pl new file mode 100755 index 0000000000..24d99246da --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_28884.pl @@ -0,0 +1,25 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "28884", + description => "Add 'ElasticsearchEscapeCharacters' and 'OpacElasticsearchEscapeCharacters' system preferences", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) + VALUES ('ElasticsearchEscapeCharacters', '', NULL, 'List of special characters that should always be escaped in intranet searches', 'Free')} + ); + + say $out "Added new system preference 'ElasticsearchEscapeCharacters'"; + + $dbh->do( + q{ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) + VALUES ('OpacElasticsearchEscapeCharacters', '', NULL, 'List of special characters that should always be escaped in intranet searches', 'Free')} + ); + + say $out "Added new system preference 'OpacElasticsearchEscapeCharacters'"; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 585d7a5d8d..c0688e1265 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -242,6 +242,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('EdifactLSQ', 'location', 'location|ccode|', 'Map EDI sequence code (GIR+LSQ) to Koha Item field, empty to ignore', 'Choice'), ('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'), ('ElasticsearchCrossFields', '1', NULL, 'Enable "cross_fields" option for searches using Elastic search.', 'YesNo'), +('ElasticsearchEscapeCharacters', '', NULL, 'List of special characters that should always be escaped in intranet searches', 'Free'), ('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL), ('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL), ('ElasticsearchMARCFormat', 'base64ISO2709', 'base64ISO2709|ARRAY', 'Elasticsearch MARC format. ISO2709 format is recommended as it is faster and takes less space, whereas array is searchable.', 'Choice'), @@ -509,6 +510,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OPACdidyoumean','',NULL,'Did you mean? configuration for the OPAC. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free'), ('OPACDisableSendList','0',NULL,'Allow OPAC users to email lists via a "Send list" button','YesNo'), ('OPACDisplay856uAsImage','OFF','OFF|Details|Results|Both','Display the URI in the 856u field as an image, the corresponding OPACXSLT option must be on','Choice'), +('OpacElasticsearchEscapeCharacters', '', NULL, 'List of special characters that should always be escaped in intranet searches', 'Free'), ('OpacExportOptions','bibtex,dc,marcxml,marc8,utf8,marcstd,mods,ris,isbd',NULL,'Define export options available on OPAC detail page.','multiple'), ('OPACFallback', 'prog', 'bootstrap|prog', 'Define the fallback theme for the OPAC interface.', 'Themes'), ('OpacFavicon','',NULL,'Enter a complete URL to an image to replace the default Koha favicon on the OPAC','Free'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref index 99c045d696..f8519bda77 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref @@ -131,6 +131,14 @@ Searching: - "
ccode: [REF,ARC]

- would mark all REF and ARC collections (Reference and Archives) items as unavailable in Z3950 results.

" - "You can define multiple keys and values, items meeting ANY of the criteria will be marked unavailable:

" - "
itype: [REF]
holdingbranch: [REPAIR]

- would mark all reference items AND items at the REPAIR branch as unavailable." + - + - "The following characters will always be escaped in intranet searches (with Elasticsearch):" + - pref: ElasticsearchEscapeCharacters + class: short + - ".
" + - "The following characters will always be escaped in OPAC searches (with Elasticsearch):" + - pref: OpacElasticsearchEscapeCharacters + class: short Search form: - - pref: LoadSearchHistoryToTheFirstLoggedUser -- 2.39.5