From 8194419144d05dc64617d8569810be2ff7bbda04 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 28 Mar 2023 17:02:19 +0200 Subject: [PATCH] Bug 33353: Add compatibility with Search::Elasticsearch 8.0 For some reasons, with Search::Elasticsearch 8.0 JSON::true is interpreted as 1 and Elasticsearch will always respond that it found "at least 1 record". Something like this: { total => { value => 1, relation => 'gte' } } Replacing JSON::true by \1 works with every version of Search::Elasticsearch I tested (6.80, 7.717, 8.0) Also worth noting: Search::Elasticsearch will stop being supported by Elastic https://github.com/elastic/elasticsearch-perl/issues/220 We might need to find an alternative for future versions of Elasticsearch Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Philip Orr Signed-off-by: Tomas Cohen Arazi --- Koha/SearchEngine/Elasticsearch/Search.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm index e8e4412b56..933b52f79d 100644 --- a/Koha/SearchEngine/Elasticsearch/Search.pm +++ b/Koha/SearchEngine/Elasticsearch/Search.pm @@ -94,7 +94,7 @@ sub search { my $results = eval { $elasticsearch->search( index => $self->index_name, - track_total_hits => JSON::true, + track_total_hits => \1, body => $query ); }; @@ -124,7 +124,7 @@ sub count { # and just return number of hits my $result = $elasticsearch->search( index => $self->index_name, - track_total_hits => JSON::true, + track_total_hits => \1, body => $query ); -- 2.39.5