From d2b5870aded83cdf849566dff2d587c8087d09c1 Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Mon, 17 Dec 2018 16:22:58 +0200 Subject: [PATCH] Bug 21974: Make Elasticsearch connection settings configurable Default settings are appended in get_elasticsearch_params so that there's a central place for them. Defaults can be overridden in koha-conf.xml. Test plan: 1. Verify that searches still work with the patch applied. 2. Verify that search fails after adding the following under in koha-conf.xml: Static 3. Verify that search fails after adding the following under in koha-conf.xml: FOO Signed-off-by: Josef Moravec Signed-off-by: Martin Renvoize --- Koha/SearchEngine/Elasticsearch.pm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm index 5cd0ad968a..9a9e50baa8 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -86,12 +86,7 @@ sub get_elasticsearch { my $self = shift @_; unless (defined $self->{elasticsearch}) { my $conf = $self->get_elasticsearch_params(); - $self->{elasticsearch} = Search::Elasticsearch->new( - client => "5_0::Direct", - nodes => $conf->{nodes}, - cxn_pool => 'Sniff', - request_timeout => 60 - ); + $self->{elasticsearch} = Search::Elasticsearch->new($conf); } return $self->{elasticsearch}; } @@ -141,12 +136,16 @@ sub get_elasticsearch_params { else { die "No elasticsearch servers were specified in koha-conf.xml.\n"; } - die "No elasticserver index_name was specified in koha-conf.xml.\n" + die "No elasticsearch index_name was specified in koha-conf.xml.\n" if ( !$es->{index_name} ); # Append the name of this particular index to our namespace $es->{index_name} .= '_' . $self->index; $es->{key_prefix} = 'es_'; + $es->{client} //= '5_0::Direct'; + $es->{cxn_pool} //= 'Sniff'; + $es->{request_timeout} //= 60; + return $es; } -- 2.20.1