Bug 12478: abort early if there's no elasticserch definition
authorRobin Sheat <robin@catalyst.net.nz>
Mon, 5 Oct 2015 04:44:14 +0000 (17:44 +1300)
committerBrendan Gallagher <brendan@bywatersolutions.com>
Tue, 26 Apr 2016 20:20:10 +0000 (20:20 +0000)
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
misc/search_tools/rebuild_elastic_search.pl

index 8d19dd9..af536f0 100755 (executable)
@@ -83,6 +83,7 @@ Full documentation.
 
 use autodie;
 use Getopt::Long;
+use C4::Context;
 use Koha::Authority;
 use Koha::BiblioUtils;
 use Koha::ElasticSearch::Indexer;
@@ -118,6 +119,8 @@ unless ($index_authorities || $index_biblios) {
 pod2usage(1) if $help;
 pod2usage( -exitstatus => 0, -verbose => 2 ) if $man;
 
+sanity_check();
+
 my $next;
 if ($index_biblios) {
     _log(1, "Indexing biblios\n");
@@ -189,6 +192,13 @@ sub do_reindex {
     _log( 1, "$count records indexed.\n" );
 }
 
+# Checks some basic stuff to ensure that it's sane before we start.
+sub sanity_check {
+    # Do we have an elasticsearch block defined?
+    my $conf = C4::Context->config('elasticsearch');
+    die "No 'elasticsearch' block is defined in koha-conf.xml.\n" if ( !$conf );
+}
+
 # Output progress information.
 #
 #   _log($level, $msg);