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 <elasticsearch> in koha-conf.xml:
<cxn_pool>Static</cxn_pool>
3. Verify that search fails after adding the following under <elasticsearch> in koha-conf.xml:
<cxn_pool>FOO</cxn_pool>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 65f35447e9)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
c1d1880aea
commit
9ef8a3e328
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue