From ec6b01b8215c78d6f18413b686c767673f8ddef4 Mon Sep 17 00:00:00 2001
From: David Gustafsson <david.gustafsson@ub.gu.se>
Date: Mon, 9 Mar 2020 11:48:13 +0100
Subject: [PATCH] Bug 24823: Fix spelling error and remove last of Catmandu

---
 Koha/SearchEngine/Elasticsearch/Browse.pm  | 19 +++++++------------
 Koha/SearchEngine/Elasticsearch/Indexer.pm |  2 +-
 cpanfile                                   |  2 --
 3 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/Koha/SearchEngine/Elasticsearch/Browse.pm b/Koha/SearchEngine/Elasticsearch/Browse.pm
index 441daf32a6..1153e68ac5 100644
--- a/Koha/SearchEngine/Elasticsearch/Browse.pm
+++ b/Koha/SearchEngine/Elasticsearch/Browse.pm
@@ -49,10 +49,6 @@ as "suggestible" in the database when indexing takes place.
 use base qw(Koha::SearchEngine::Elasticsearch);
 use Modern::Perl;
 
-use Catmandu::Store::ElasticSearch;
-
-Koha::SearchEngine::Elasticsearch::Browse->mk_accessors(qw( store ));
-
 =head2 browse
 
     my $results = $browser->browse($prefix, $field, \%options);
@@ -108,15 +104,14 @@ in order of some form of relevance.
 sub browse {
     my ($self, $prefix, $field, $options) = @_;
 
-    my $params = $self->get_elasticsearch_params();
-    $self->store(
-        Catmandu::Store::ElasticSearch->new(
-            %$params,
-        )
-    ) unless $self->store;
-
     my $query = $self->_build_query($prefix, $field, $options);
-    my $results = $self->store->bag->search(%$query);
+    my $elasticsearch = $self->get_elasticsearch();
+    my $conf = $self->get_elasticsearch_params();
+    my $results = $elasticsearch->search(
+        index => $conf->{index_name},
+        body => $query
+    );
+
     return $results->{suggest}{suggestions}[0]{options};
 }
 
diff --git a/Koha/SearchEngine/Elasticsearch/Indexer.pm b/Koha/SearchEngine/Elasticsearch/Indexer.pm
index 1fe2d6cc17..aa50bc38ca 100644
--- a/Koha/SearchEngine/Elasticsearch/Indexer.pm
+++ b/Koha/SearchEngine/Elasticsearch/Indexer.pm
@@ -297,7 +297,7 @@ sub delete_index {
         body => \@body,
     );
     if ($result->{errors}) {
-        croak "An Elasticsearch error occured during bulk delete";
+        croak "An Elasticsearch error occurred during bulk delete";
     }
 }
 
diff --git a/cpanfile b/cpanfile
index f7d69c3f84..b123f578ce 100644
--- a/cpanfile
+++ b/cpanfile
@@ -134,8 +134,6 @@ recommends 'Archive::Zip', '1.30';
 recommends 'Array::Utils', '0.5';
 recommends 'CGI::Session::Driver::memcached', '0.04';
 recommends 'Cache::FastMmap', '1.34';
-recommends 'Catmandu::MARC', '1.241';
-recommends 'Catmandu::Store::ElasticSearch', '>= 0.0507, <= 0.512';
 recommends 'DBD::SQLite2', '0.33';
 recommends 'Devel::Cover', '0.89';
 recommends 'File::Copy', '2.08';
-- 
2.20.1