Bug 32491

Summary: Can no longer search patrons in format 'surname, firstname'
Product: Koha Reporter: Laura Escamilla <Laura.escamilla>
Component: PatronsAssignee: Jonathan Druart <jonathan.druart>
Status: RESOLVED FIXED QA Contact: Kyle M Hall (khall) <kyle>
Severity: normal    
Priority: P5 - low CC: admin, arthur.suzuki, david, dcook, esther.melander, gmcharlt, jonathan.druart, kyle.m.hall, kyle, lucas
Version: MainKeywords: regression, rel_22_11_candidate
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.02,22.05.09
Circulation function:
Bug Depends on: 30063    
Bug Blocks:    
Attachments: Bug 32491: Split patron search terms on comma
Bug 32491: Split patron search terms on comma
Bug 32491: Split patron search terms on comma - autocomplete
Bug 32491: Split patron search terms on comma
Bug 32491: Split patron search terms on comma - autocomplete
Bug 32491: Split patron search terms on comma
Bug 32491: Split patron search terms on comma - autocomplete

Description Laura Escamilla 2022-12-19 16:41:51 UTC
Using a comma when searching for patrons such as "Smith, John" will show no results. However, searching for "Smith John" will pull all related patron records.
Comment 1 Katrin Fischer 2022-12-19 16:44:24 UTC
I don't think the special character is the issue here - the problem is, that the comma is not part of the data, so you get no match. As we are doing an SQL based search here I am not sure what could be done to make this easily possible - removing the comma or other characters by default might break some searches?
Comment 2 David Cook 2022-12-19 22:21:42 UTC
(In reply to Katrin Fischer from comment #1)
> As we are doing an
> SQL based search here I am not sure what could be done to make this easily
> possible - removing the comma or other characters by default might break
> some searches?

Hmm maybe normalizing the search to remove punctuation isn't a bad idea. 

I normalize the search for phone number (see bug 23817) although it can actually be fairly difficult to do in the newest versions of Koha because of how we use the REST API for patron search...
Comment 3 Lucas Gass (lukeg) 2023-01-03 17:43:37 UTC
This also effects wildcard searches. Previously you could search for a cardnumber like '2913*' and that would return all patrons with cardnumbers starting with '2913'. Now it tries searching for the exact match '2352*' and returns nothing.
Comment 4 Katrin Fischer 2023-01-03 17:58:16 UTC
(In reply to Lucas Gass from comment #3)
> This also effects wildcard searches. Previously you could search for a
> cardnumber like '2913*' and that would return all patrons with cardnumbers
> starting with '2913'. Now it tries searching for the exact match '2352*' and
> returns nothing.

I don't think * has worked, but it automatically did a begin with. % should probably still work?
Comment 5 PPLCS 2023-01-03 21:26:37 UTC
We desperately need this fixed!
Comment 6 Katrin Fischer 2023-01-04 17:54:07 UTC
(In reply to PPLCS from comment #5)
> We desperately need this fixed!

Can you explain the problem a bit more as it manifests for you?

Has this worked before? I am not aware of it, but not totally user as we had some changes to patron search recently. 

As I said the problem with comma is that it's not part of the data, it's not failing because of being a special character. If the comma was in your data, you should be able to search for it without issues.
Comment 7 PPLCS 2023-01-04 19:06:19 UTC
Entering in "Doe, John" in the patron search field worked before the last Koha update. As a librarian I'm hardwired to type in last name first, comma, first name. So this is a real problem when looking up patrons.
Comment 8 Owen Leonard 2023-01-04 20:32:17 UTC
(In reply to Katrin Fischer from comment #6)
 
> Has this worked before? 

Patron searching works correctly in 22.05 with the comma included, so this is a regression.
Comment 9 Katrin Fischer 2023-01-04 20:33:12 UTC
(In reply to Owen Leonard from comment #8)
> (In reply to Katrin Fischer from comment #6)
>  
> > Has this worked before? 
> 
> Patron searching works correctly in 22.05 with the comma included, so this
> is a regression.

Thx for confirming, I already marked it as such and added Joubu in CC.
Comment 10 Jonathan Druart 2023-01-05 08:27:47 UTC
Created attachment 145054 [details] [review]
Bug 32491: Split patron search terms on comma

Previous behaviour allowed search 'surname, firstname'. We should remove
the comma from the search terms.

Test plan:
On the main patron search, search for "surname, firstname" and confirm
that with this patch applied the search returns the expected results.
Comment 11 Jonathan Druart 2023-01-05 08:32:57 UTC
(In reply to Owen Leonard from comment #8)
> (In reply to Katrin Fischer from comment #6)
>  
> > Has this worked before? 
> 
> Patron searching works correctly in 22.05 with the comma included, so this
> is a regression.

Hum I am expecting a regression caused by 30063 or 30093 and both are in 22.05

Also I see, in 22.05.x
includes/patron-search.inc
314                     let patterns = pattern.split(' ').filter(function(s){ return s.length });

I haven't tested though.
Comment 12 David Nind 2023-01-05 13:10:10 UTC
Created attachment 145058 [details] [review]
Bug 32491: Split patron search terms on comma

Previous behaviour allowed search 'surname, firstname'. We should remove
the comma from the search terms.

Test plan:
On the main patron search, search for "surname, firstname" and confirm
that with this patch applied the search returns the expected results.

Signed-off-by: David Nind <david@davidnind.com>
Comment 13 David Nind 2023-01-05 13:16:41 UTC
Testing notes (using KTD):

1. For me, this fixes the search from the 'Search for patron' box on the patrons page

2. In the header search it continues to work, however I note that if you search for example for 'burton' then this gives you the autocomplete results. However, if you search for 'Burton,' it doesn't show in autocomplete (but does give you the correct result when you click the button to search). Searching for 'burton mary' will give you the autocomplete results.
Comment 14 Esther Melander 2023-01-05 19:33:06 UTC
In regards to the wild card searches in the patron field, Should this be a separate ticket?

Prior to our upgrade to 22.05, we could do searches like 2913*3456 and have it return results. After the upgrade this no longer works.

The % wildcard appears to work in the search example above. However the % as a wildcard is odd when compared with how other search indexes work. Most major search engines use either an asterisk or a question mark. The same is true with searching indexes at Ancestry or Family Search. The asterisk replaces multiple characters and the question mark replaces a single character. Most of our staff is accustomed to using an asterisk and trying to adapt to a different nomenclature and keyboard position has proven difficult.
Comment 15 Jonathan Druart 2023-01-06 09:10:28 UTC
Created attachment 145077 [details] [review]
Bug 32491: Split patron search terms on comma - autocomplete
Comment 16 Jonathan Druart 2023-01-06 09:10:52 UTC
(In reply to David Nind from comment #13)
> 2. In the header search it continues to work, however I note that if you
> search for example for 'burton' then this gives you the autocomplete
> results. However, if you search for 'Burton,' it doesn't show in
> autocomplete (but does give you the correct result when you click the button
> to search). Searching for 'burton mary' will give you the autocomplete
> results.

Good catch, that should be fixed here I think. The last patch is fixing it.

(In reply to Esther Melander from comment #14)
> In regards to the wild card searches in the patron field, Should this be a
> separate ticket?

Yes, please open a separate bug report.
Comment 17 David Nind 2023-01-06 11:05:10 UTC
Created attachment 145078 [details] [review]
Bug 32491: Split patron search terms on comma

Previous behaviour allowed search 'surname, firstname'. We should remove
the comma from the search terms.

Test plan:
On the main patron search, search for "surname, firstname" and confirm
that with this patch applied the search returns the expected results.

Signed-off-by: David Nind <david@davidnind.com>
Comment 18 David Nind 2023-01-06 11:05:15 UTC
Created attachment 145079 [details] [review]
Bug 32491: Split patron search terms on comma - autocomplete

Signed-off-by: David Nind <david@davidnind.com>
Comment 19 Kyle M Hall (khall) 2023-01-06 15:04:45 UTC
Created attachment 145083 [details] [review]
Bug 32491: Split patron search terms on comma

Previous behaviour allowed search 'surname, firstname'. We should remove
the comma from the search terms.

Test plan:
On the main patron search, search for "surname, firstname" and confirm
that with this patch applied the search returns the expected results.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 20 Kyle M Hall (khall) 2023-01-06 15:04:56 UTC
Created attachment 145084 [details] [review]
Bug 32491: Split patron search terms on comma - autocomplete

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 21 Tomás Cohen Arazi (tcohen) 2023-01-11 23:55:50 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 22 Jacob O'Mara 2023-01-13 16:25:03 UTC
Nice work, thanks everyone!

Pushed to 22.11.x for the next release.
Comment 23 Michael Adamyk 2023-01-13 18:36:11 UTC
(In reply to Owen Leonard from comment #8)
> (In reply to Katrin Fischer from comment #6)
>  
> > Has this worked before? 
> 
> Patron searching works correctly in 22.05 with the comma included, so this
> is a regression.

I'm running Koha 22.05.07, and this is affecting us. We can't do patron searches with commas or we get no results. I don't know if it was present in previous versions of 22.05 or not.
Comment 24 Lucas Gass (lukeg) 2023-01-24 18:50:57 UTC
I have backported the first patch to 22.05.x and that fixes the problem. The 2nd patch is not needed in 22.05.x as 'patron-autocomplete.js' does not exist yet. That would be dependent on Bug 30578.
Comment 25 Arthur Suzuki 2023-01-26 13:34:39 UTC
This one depends on 30063 which is not available on 21.11.x.
not backporting.