Bug 31013 - Reserved words as branchcodes cause search error in Elasticsearch
Summary: Reserved words as branchcodes cause search error in Elasticsearch
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Nick Clemens (kidclamp)
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-22 13:18 UTC by Nick Clemens (kidclamp)
Modified: 2023-06-08 22:26 UTC (History)
6 users (show)

See Also:
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
Circulation function:


Attachments
Bug 31013: Quote branchcodes in Elasticsearch limits (7.81 KB, patch)
2022-06-22 13:21 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 31013: Quote branchcodes in Elasticsearch limits (7.87 KB, patch)
2022-06-22 13:56 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens (kidclamp) 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 (kidclamp) 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 (ashimema) 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 (ashimema) 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 (tcohen) 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 (lukeg) 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.