Bug 34941

Summary: Patron search to find patrons with hyphens when they haven't been added in the search
Product: Koha Reporter: wainuiwitikapark
Component: PatronsAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: didier.gautheron, gmcharlt, jonathan.druart, kyle.m.hall, wainuiwitikapark
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 32772    
Bug Blocks:    

Description wainuiwitikapark 2023-09-28 01:37:01 UTC
e.g. The behaviour of Koha used to be that if you searched patrons for "Witika Park" it would return "Wainui Witika-Park".

Now you have to specifically search "Witika-Park" for the patron to show up i.e. "Witika Park" does not return any results
Comment 1 Didier Gautheron 2023-09-28 12:19:16 UTC
And searching for "le bon" doesn't work anymore too since moving to rest API for search.
Comment 2 Jonathan Druart 2023-10-12 08:14:03 UTC
Hi Wainui, please try this change:

diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js
index 86792041afe..6bdee1f0723 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js
+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js
@@ -555,7 +555,7 @@ function buildPatronSearchQuery(term, options) {
     let q = [];
     let leading_wildcard;
     let search_fields;
-    let patterns = term.split(/[\s,]+/).filter(function (s) { return s.length });
+    let patterns = term.split(/[\s,-]+/).filter(function (s) { return s.length });
 
     // Bail if no patterns
     if (patterns.length == 0) {
Comment 3 Jonathan Druart 2023-10-12 08:16:02 UTC
(In reply to Didier Gautheron from comment #1)
> And searching for "le bon" doesn't work anymore too since moving to rest API
> for search.

Please provide more info. Splitting on spaces should work.
Comment 4 Didier Gautheron 2023-10-12 08:28:48 UTC
Hi,

before if there's a composed name like "foo-bar" searching "foo-bar" or "foo bar" worked, now "foo bar" doesn't work.
Comment 5 Jonathan Druart 2023-10-13 06:57:32 UTC
Sorry, the diff on comment #2 won't address the problem.

Didier, I think what you describe is exactly what Wainui described on comment 0.

If you want to work you need to select "Search type: contains".

I am not sure it is a regression since the move to the REST API, we already had this start with/contains options.
Comment 6 Didier Gautheron 2023-10-13 10:30:43 UTC
Hi,

Yes it's fixed by using the new syspref DefaultPatronSearchMethod.