From 3d7fc65e58449388bbb4377e7b8131f200447eb5 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 19 Oct 2017 10:23:54 -0300 Subject: [PATCH] Issue #12: Handle ES indexes and mappings Signed-off-by: Tomas Cohen Arazi --- do_all_you_can_do.pl | 16 +++++++++++++--- populate_db.pl | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/do_all_you_can_do.pl b/do_all_you_can_do.pl index 6867ffd..9708cfc 100644 --- a/do_all_you_can_do.pl +++ b/do_all_you_can_do.pl @@ -23,11 +23,15 @@ my $instance; my $userid; my $password; +my $koha_dir; +my $elasticsearch; GetOptions( + 'elasticsearch' => \$elasticsearch, 'instance=s' => \$instance, - 'userid=s' => \$userid, - 'password=s' => \$password + 'koha_dir=s' => \$koha_dir, + 'password=s' => \$password, + 'userid=s' => \$userid ); my $create_superlibrarian_opts = ""; @@ -38,6 +42,7 @@ $instance //= 'kohadev'; +$koha_dir //= '/home/vagrant/kohaclone'; my $misc_dir = dirname( abs_path( $0 ) ); my ( $cmd, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ); @@ -61,6 +66,11 @@ $cmd = "sudo koha-rebuild-zebra -f -v $instance"; ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 1 ); exit(1) unless $success; -# TODO Add rebuild ES + +if ($elasticsearch) { + $cmd = "sudo koha-shell $instance -p -c 'PERL5LIB=$PERL5LIB perl $koha_dir/misc/search_tools/rebuild_elastic_search.pl -v"; + ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 1 ); + exit(1) unless $success; +} exit(0); diff --git a/populate_db.pl b/populate_db.pl index bbc7e11..6d221a9 100755 --- a/populate_db.pl +++ b/populate_db.pl @@ -21,7 +21,7 @@ use C4::Installer; use C4::Context; -#use Koha::SearchEngine::Elasticsearch; +use Koha::SearchEngine::Elasticsearch; =head1 NAME @@ -169,7 +169,7 @@ sub initialize_data { }); # Initialize ES mappings - #Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings; + Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings; } sub execute_sqlfile {