Bug 21146 - Elasticsearch 5.6+ doesn't consider '0' a valid boolean
Summary: Elasticsearch 5.6+ doesn't consider '0' a valid boolean
Status: RESOLVED DUPLICATE of bug 19893
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Bugs List
QA Contact:
URL: https://discuss.elastic.co/t/perl-and...
Keywords:
Depends on:
Blocks: 20196
  Show dependency treegraph
 
Reported: 2018-08-02 10:14 UTC by Tomás Cohen Arazi
Modified: 2019-02-14 15:35 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi 2018-08-02 10:14:34 UTC
To reproduce:
- Set SearchEngine=Zebra
- Run:
  $ kshell
 k$ prove prove t/db_dependent/Circulation/Returns.t
=> SUCCESS: Tests pass!
- Set SearchEngine=Elasticsearch
- Run:
 k$ prove prove t/db_dependent/Circulation/Returns.t
=> FAIL: Things explode because '0' is not a valid boolean for Elasticsearch (legacy fallback in past versions).
Comment 1 Tomás Cohen Arazi 2018-08-02 13:38:49 UTC
Maybe:

diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm
index 9c114fb060..c7081ee559 100644
--- a/Koha/SearchEngine/Elasticsearch.pm
+++ b/Koha/SearchEngine/Elasticsearch.pm
@@ -308,7 +308,11 @@ sub get_fixer_rules {
                 # boolean gets special handling, basically if it doesn't exist,
                 # it's added and set to false. Otherwise we can't query it.
                 push @rules,
-                  "unless exists('$name') add_field('$name', 0) end";
+                  "if is_true('$name')
+                     add_field('$name', 'true')
+                   else
+                     add_field('$name', 'false')
+                   end";
             }
             if ($type eq 'sum' ) {
                 push @rules, "sum('$name')";
Comment 2 Joonas Kylmälä 2018-10-19 12:41:02 UTC
if accepted, Bug #19893 will fix this.
Comment 3 Nick Clemens 2019-02-14 15:35:27 UTC

*** This bug has been marked as a duplicate of bug 19893 ***