Bug 24372

Summary: Elasticsearch - cannot search for titles containing a colon next to a search term using the colon
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: Searching - ElasticsearchAssignee: Bugs List <koha-bugs>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P5 - low CC: cbrannon, fridolin.somers, joonas.kylmala, margaret, marjorie.barry-vila, sbcornell
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27597
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:

Description Nick Clemens (kidclamp) 2020-01-07 19:30:51 UTC
Using an example record in the testing DB, try searching for:
Pictura murală din nordul Moldovei: modificari estetice si restarare = Mural painting in the north of Moldavia: aesthetic modification and restoration

In ES the search fails. If you look at the query we end up with terms like:
Moldoveimodificari AND Moldaviaaesthetic

This is because of this line in Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
 935     # Remove unquoted colons that have whitespace on either side of them
 936     $term =~ s/(\:[:\s]+|[:\s]+:)$lookahead//g;


Removing colons with a space on either side, we must be careful to put that space back:
 936     $term =~ s/(\:[:\s]+|[:\s]+:)$lookahead/ /g;
Comment 1 Fridolin Somers 2020-11-10 14:17:27 UTC
Code has changed :
    $term =~ s/(:+)(\s+)$lookahead/$2/g;
    $term =~ s/(\s+)(:+)$lookahead/$1/g;

But bug looks still valid.
Comment 2 Fridolin Somers 2020-11-10 14:22:40 UTC
Enable DumpSearchQueryTemplate syspref and look in HTML code to "query_string" > "query"
Comment 3 Joonas Kylmälä 2020-11-11 11:50:47 UTC
(In reply to Fridolin Somers from comment #1)
> Code has changed :
>     $term =~ s/(:+)(\s+)$lookahead/$2/g;
>     $term =~ s/(\s+)(:+)$lookahead/$1/g;
> 
> But bug looks still valid.

This new code should fix this, at least for me this search now works with this new code.
Comment 4 Christopher Brannon 2021-03-09 20:26:52 UTC
Running into this problem.  Would love for this fix to be released.
Comment 5 Nick Clemens (kidclamp) 2021-03-12 13:24:03 UTC

*** This bug has been marked as a duplicate of bug 24567 ***