As noted at https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11175#c522 and https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29418#c11, an unquoted Host-item query returned by Koha::Biblio->get_components_query can cause syntax errors in Zebra.
Reference on Elasticsearch syntax: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax Reference on CCL/Zebra syntax: https://software.indexdata.com/yaz/doc/tools.html#ccl.syntax The CCL documentation isn't great and Koha has never handled CCL very well...
Created attachment 135445 [details] [review] Bug 30865: Double-quote Host-item in Koha::Biblio->get_components_query This patch adds double quotes around the term qualified by "Host-item" in Koha::Biblio->get_components_query(). Without them, reserved charactrs like "=" will cause syntax errors like "CCL parsing error (10014) Unknown qualifier ZOOM for query: Host-item=(MyTitle = Mysubtitle) at /usr/share/koha/lib/C4/Search.pm line 245." Test plan: 0) Don't apply the patch 1) Create biblio with title and subtitle like (MyTitle : MySubtitle) 2) Note the warning "There was an error searching for analytic records, please see the logs for details." on the detail page 3) Apply the patch 4) koha-plack --restart kohadev 5) Refresh the detail page 6) Note that the warning message is gone 7) prove t/db_dependent/Koha/Biblio.t
Created attachment 136669 [details] [review] Bug 30865: Double-quote Host-item in Koha::Biblio->get_components_query This patch adds double quotes around the term qualified by "Host-item" in Koha::Biblio->get_components_query(). Without them, reserved charactrs like "=" will cause syntax errors like "CCL parsing error (10014) Unknown qualifier ZOOM for query: Host-item=(MyTitle = Mysubtitle) at /usr/share/koha/lib/C4/Search.pm line 245." Test plan: 0) Don't apply the patch 1) Create biblio with title and subtitle like (MyTitle : MySubtitle) 2) Note the warning "There was an error searching for analytic records, please see the logs for details." on the detail page 3) Apply the patch 4) koha-plack --restart kohadev 5) Refresh the detail page 6) Note that the warning message is gone 7) prove t/db_dependent/Koha/Biblio.t Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Thanks for working on this David, my apologies for not getting to testing it as quickly as I should. This works great, a much cleaner solution too. Tested with Zebra and Elastic and as the docs say it works well for both. In the end, this is a trivial patch so I'm going straight for QA. QA script happy, Unit tests passing, No regressions and bug is fixed. Passing QA
Pushed to master for 22.11. Nice work everyone, thanks!
(In reply to Martin Renvoize from comment #4) > Thanks for working on this David, my apologies for not getting to testing it > as quickly as I should. > > This works great, a much cleaner solution too. > > Tested with Zebra and Elastic and as the docs say it works well for both. > > In the end, this is a trivial patch so I'm going straight for QA. > > QA script happy, Unit tests passing, No regressions and bug is fixed. > > Passing QA Please look at bug 31106 ASAP.
Backported to 22.05.x for 22.05.04
backport to 21.11.x for 21.11.11
Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed. Nothing to document, marking resolved.