Bug 30153

Summary: FindDuplicate ElasticSearch should not use lowercase 'and'
Product: Koha Reporter: Thomas Klausner <domm>
Component: Searching - ElasticsearchAssignee: Bugs List <koha-bugs>
Status: CLOSED FIXED QA Contact: Martin Renvoize <martin.renvoize>
Severity: minor    
Priority: P5 - low CC: andrewfh, dcook, kyle, martin.renvoize, nick, victor
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25616
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00,21.11.04,21.05.13
Bug Depends on: 27928    
Bug Blocks:    
Attachments: Use uppercase AND to join query parts
Bug 30153: Use uppercase AND to join query parts
Bug 30153: (QA follow-up) Fix unit tests

Description Thomas Klausner 2022-02-22 14:08:32 UTC
C4::Search->FindDuplicate joins title and author using 'and' (lowercase). When this query is passed on to ElasticSearch, it interprets the lowercase 'and' as a term to search for, because the operator has to be in uppercases ('AND').
Comment 1 Thomas Klausner 2022-02-22 14:10:57 UTC
See Also 27928
Comment 2 Thomas Klausner 2022-02-22 14:20:17 UTC
Created attachment 131014 [details] [review]
Use uppercase AND to join query parts

Fix Bug 30153
Comment 3 Martin Renvoize 2022-02-22 14:39:38 UTC
Created attachment 131016 [details] [review]
Bug 30153: Use uppercase AND to join query parts

C4::Search->FindDuplicate joins title and author using 'and'
(lowercase). When this query is passed on to ElasticSearch, it
interprets the lowercase 'and' as a term to search for, because the
operator has to be in uppercases ('AND').

Test plan:
* Reproduce the bug:
- Set SearchEngine to ElasticSearch (and make sure you have the data
  indexed etc)
- Find an existing book, note the title (245a) and the author (100a)
- Create a new book (Cataloging -> New Record)
- Fill in the same title and author using the same data as in an
  existing book (and any other fields that might be required)
- Click "save"
=> A new book will be created, the Duplicate Finder has failed

* Apply the patch

* Check if it's working now:
- Create a new book (Cataloging -> New Record)
- Fill in the same title and author using the same data as in an
  existing book (and any other fields that might be required)
- Click "save"
- The DuplicateFinder should now report the already exising book

Maybe we should also check if Zebra does not have any problems with the
uppercase 'AND'? In that case, repeat the above steps, but set
SearchEngine to Zebra :-)

Sponsored-by: Steiermärkische Landesbibliothek
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2022-02-22 14:40:22 UTC
I tested against Zebra and found no obvious regressions, ES issue is resolved... Signing off.
Comment 5 Martin Renvoize 2022-02-22 16:26:07 UTC
This a trivial patch, and given I've just QA'd bug 25616 now it's been brought to my attention, I'm going to go ahead and QA this one too.

Unit test update inbound, then it'll be a pass.
Comment 6 Martin Renvoize 2022-02-22 16:28:50 UTC
Created attachment 131023 [details] [review]
Bug 30153: (QA follow-up) Fix unit tests
Comment 7 Fridolin Somers 2022-03-02 08:49:19 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 8 Kyle M Hall 2022-03-04 13:19:50 UTC
Pushed to 21.11.x for 21.11.04
Comment 9 Andrew Fuerste-Henry 2022-03-20 15:06:41 UTC
Pushed to 21.05.x for 21.05.13
Comment 10 Victor Grousset/tuxayo 2022-03-21 00:16:42 UTC
Not backported to oldoldstable (20.11.x). Feel free to ask if it's needed.