[Koha-bugs] [Bug 33406] Searching for authority with hyphen surrounded by spaces causes error 500 (with ES)

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu May 11 17:11:41 CEST 2023


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33406

--- Comment #2 from Janusz Kaczmarek <januszop at gmail.com> ---
Jonathan, thank you for the patch.  I'll test it and it most probably will do
its job.

At the same time, I'm not quite sure if all we can do is to catch error.  IMHO
it will be rather surprising for an librarian to see information about an error
and a prompt to try again while searching (with default settings) for an
existing authority (and hyphens surrounded by spaces normally occur e.g. in
corporate names or in series titles). 

Couldn't we, retaining the catching mechanism, also add somehow a correction
like this:

--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
@@ -1228,6 +1228,8 @@ sub _split_query {

     # Filter out empty values
     @tokens = grep( /\S/, @tokens );
+    # Filter out some known isolated trouble makers: -, ^, \, ~, +
+    @tokens = grep( !/^[-\^\\~\+]*$/, @tokens );

     return @tokens;
 }


[The auth 'contains' query goes always through _split_query which is called by
_truncate_terms]

This would prevent most known issues to emerge.  (I was unable, due to lack of
time, to prepare the official patch by myself).

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list