|
Lines 27-32
use List::MoreUtils qw/ any /;
Link Here
|
| 27 |
use LWP::Simple; |
27 |
use LWP::Simple; |
| 28 |
use XML::Simple; |
28 |
use XML::Simple; |
| 29 |
use Config; |
29 |
use Config; |
|
|
30 |
use Search::Elasticsearch; |
| 31 |
use Try::Tiny; |
| 30 |
|
32 |
|
| 31 |
use C4::Output; |
33 |
use C4::Output; |
| 32 |
use C4::Auth; |
34 |
use C4::Auth; |
|
Lines 38-45
use Koha::Acquisition::Currencies;
Link Here
|
| 38 |
use Koha::Patrons; |
40 |
use Koha::Patrons; |
| 39 |
use Koha::Caches; |
41 |
use Koha::Caches; |
| 40 |
use Koha::Config::SysPrefs; |
42 |
use Koha::Config::SysPrefs; |
|
|
43 |
use Koha::SearchEngine::Elasticsearch; |
| 44 |
|
| 41 |
use C4::Members::Statistics; |
45 |
use C4::Members::Statistics; |
| 42 |
|
46 |
|
|
|
47 |
|
| 43 |
#use Smart::Comments '####'; |
48 |
#use Smart::Comments '####'; |
| 44 |
|
49 |
|
| 45 |
my $query = new CGI; |
50 |
my $query = new CGI; |
|
Lines 260-265
if ( !defined C4::Context->config('use_zebra_facets') ) {
Link Here
|
| 260 |
} |
265 |
} |
| 261 |
} |
266 |
} |
| 262 |
|
267 |
|
|
|
268 |
if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) { |
| 269 |
# Check ES configuration health and runtime status |
| 270 |
|
| 271 |
my $es_status; |
| 272 |
my $es_config_error; |
| 273 |
my $es_running = 1; |
| 274 |
|
| 275 |
my $es_conf; |
| 276 |
try { |
| 277 |
$es_conf = Koha::SearchEngine::Elasticsearch::_read_configuration(); |
| 278 |
} |
| 279 |
catch { |
| 280 |
if ( ref($_) eq 'Koha::Exceptions::Config::MissingEntry' ) { |
| 281 |
$template->param( elasticsearch_fatal_config_error => $_->message ); |
| 282 |
$es_config_error = 1; |
| 283 |
} |
| 284 |
warn p($_); |
| 285 |
}; |
| 286 |
if ( !$es_config_error ) { |
| 287 |
|
| 288 |
my $biblios_index_name = $es_conf->{index_name} . "_" . $Koha::SearchEngine::BIBLIOS_INDEX; |
| 289 |
my $authorities_index_name = $es_conf->{index_name} . "_" . $Koha::SearchEngine::AUTHORITIES_INDEX; |
| 290 |
|
| 291 |
my @indexes = ($biblios_index_name, $authorities_index_name); |
| 292 |
# TODO: When new indexes get added, we could have other ways to |
| 293 |
# fetch the list of available indexes (e.g. plugins, etc) |
| 294 |
$es_status->{nodes} = $es_conf->{nodes}; |
| 295 |
my $es = Search::Elasticsearch->new({ nodes => $es_conf->{nodes} }); |
| 296 |
|
| 297 |
foreach my $index ( @indexes ) { |
| 298 |
my $count; |
| 299 |
try { |
| 300 |
$count = $es->indices->stats( index => $index ) |
| 301 |
->{_all}{primaries}{docs}{count}; |
| 302 |
} |
| 303 |
catch { |
| 304 |
if ( ref($_) eq 'Search::Elasticsearch::Error::Missing' ) { |
| 305 |
push @{ $es_status->{errors} }, "Index not found ($index)"; |
| 306 |
$count = -1; |
| 307 |
} |
| 308 |
elsif ( ref($_) eq 'Search::Elasticsearch::Error::NoNodes' ) { |
| 309 |
$es_running = 0; |
| 310 |
} |
| 311 |
else { |
| 312 |
# TODO: when time comes, we will cover more use cases |
| 313 |
die $_; |
| 314 |
} |
| 315 |
}; |
| 316 |
|
| 317 |
push @{ $es_status->{indexes} }, |
| 318 |
{ |
| 319 |
index_name => $index, |
| 320 |
count => $count |
| 321 |
}; |
| 322 |
} |
| 323 |
$es_status->{running} = $es_running; |
| 324 |
|
| 325 |
$template->param( elasticsearch_status => $es_status ); |
| 326 |
} |
| 327 |
} |
| 328 |
|
| 263 |
# Sco Patron should not contain any other perms than circulate => self_checkout |
329 |
# Sco Patron should not contain any other perms than circulate => self_checkout |
| 264 |
if ( C4::Context->preference('WebBasedSelfCheck') |
330 |
if ( C4::Context->preference('WebBasedSelfCheck') |
| 265 |
and C4::Context->preference('AutoSelfCheckAllowed') |
331 |
and C4::Context->preference('AutoSelfCheckAllowed') |