Bug 31013

Summary: Reserved words as branchcodes cause search error in Elasticsearch
Product: Koha Reporter: Nick Clemens <nick>
Component: Searching - ElasticsearchAssignee: Nick Clemens <nick>
Status: CLOSED FIXED QA Contact: Martin Renvoize <martin.renvoize>
Severity: normal    
Priority: P5 - low CC: arthur.suzuki, dcook, lucas, martin.renvoize, tomascohen, victor
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00, 22.05.04, 21.11.11
Attachments: Bug 31013: Quote branchcodes in Elasticsearch limits
Bug 31013: Quote branchcodes in Elasticsearch limits

Description Nick Clemens 2022-06-22 13:18:50 UTC
To recreate:
0 - Be using Elasticsearch with Koha
1 - Add a new branch code:OR name:Orly
2 - Add an item to this branch
3 - Use advanced search to limit search to only Orly
4 - The search fails!
Comment 1 Nick Clemens 2022-06-22 13:21:13 UTC
Created attachment 136412 [details] [review]
Bug 31013: Quote branchcodes in Elasticsearch limits

This patch adds quoting when handling branchcodes in searching in order
to prevent errors when branchcodes are reserved words in ES

To test:
0 - Be using Elasticsearch with Koha
1 - Add a new branch code:OR name:Orly
2 - Add an item to this branch
3 - Use advanced search to limit search to only Orly
4 - Oh really bad, the search fails!
5 - Apply patch
6 - Repeat search
7 - Oh really good, the search succeeds
8 - prove t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t
Comment 2 Martin Renvoize 2022-06-22 13:56:05 UTC
Created attachment 136419 [details] [review]
Bug 31013: Quote branchcodes in Elasticsearch limits

This patch adds quoting when handling branchcodes in searching in order
to prevent errors when branchcodes are reserved words in ES

To test:
0 - Be using Elasticsearch with Koha
1 - Add a new branch code:OR name:Orly
2 - Add an item to this branch
3 - Use advanced search to limit search to only Orly
4 - Oh really bad, the search fails!
5 - Apply patch
6 - Repeat search
7 - Oh really good, the search succeeds
8 - prove t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 3 Martin Renvoize 2022-06-22 13:56:47 UTC
Trivial and clear fix with unit tests included.. going straight for QA on this one.

QA scripts are happy, testing proves the fix works, Unit tests all passing and changes make sense.

Passing QA
Comment 4 Tomás Cohen Arazi 2022-06-23 14:36:27 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 5 David Cook 2022-06-24 01:51:58 UTC
Btw, Nick, you made me chuckle with "Orly" heh.
Comment 6 Lucas Gass 2022-07-29 15:14:15 UTC
Backported to 22.05.x for 22.05.04
Comment 7 Arthur Suzuki 2022-08-11 07:21:56 UTC
pushed to 21.11.x for 21.11.11
Comment 8 Victor Grousset/tuxayo 2022-08-13 16:06:22 UTC
Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed.

Nothing to document, marking resolved.