From a1df722c473418df97c14eb3519a597ab63fad7b Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 15 Apr 2025 11:47:13 +0000 Subject: [PATCH] Bug 39636: Add option to specify which indexes to check This patch adds --biblios and --authorities options to the script to allow checking only a single index To test: 0 - Apply patch 1 - perl misc/maintenance/compare_es_to_db.pl 2 - biblios and authorities are checked 3 - perl misc/maintenance/compare_es_to_db.pl -b 4 - Only biblios are checked 5 - perl misc/maintenance/compare_es_to_db.pl -a 6 - Only authorities are checked 7 - perl misc/maintenance/compare_es_to_db.pl -a -b 8 - Both indexes are checked Signed-off-by: Tomas Cohen Arazi Edit: tidied --- misc/maintenance/compare_es_to_db.pl | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/misc/maintenance/compare_es_to_db.pl b/misc/maintenance/compare_es_to_db.pl index b5de6d0db3f..5a5635ee43c 100755 --- a/misc/maintenance/compare_es_to_db.pl +++ b/misc/maintenance/compare_es_to_db.pl @@ -43,10 +43,15 @@ use Koha::SearchEngine::Elasticsearch; my $help; my $fix; +my $biblios; +my $authorities; +my @indices = (); GetOptions( - 'h|help' => \$help, - 'f|fix' => \$fix, + 'h|help' => \$help, + 'f|fix' => \$fix, + 'b|biblios' => \$biblios, + 'a|authorities' => \$authorities ); my $usage = <<'ENDUSAGE'; @@ -54,12 +59,17 @@ my $usage = <<'ENDUSAGE'; This script finds differences between the records on the Koha database and the Elasticsearch index. -The `--fix` option switch can be passed to try fixing them. +You can pass `--biblios` or `--authorities` to limit the check to a single index. +Both will be checked if nothing is specified. + +The `--fix` option switch can be passed to try fixing differences. This script has the following parameters : - -f|--fix Try to fix errors - -h|--help Print this message + -b|--biblios Check the biblios index + -a|authorities Check the authorities index + -f|--fix Try to fix errors + -h|--help Print this message ENDUSAGE @@ -68,7 +78,12 @@ if ($help) { exit; } -foreach my $index ( ( 'biblios', 'authorities' ) ) { +push @indices, "biblios" if $biblios; +push @indices, "authorities" if $authorities; + +@indices = ( "biblios", "authorities" ) unless @indices; + +foreach my $index (@indices) { print "=================\n"; print "Checking $index\n"; my @db_records = -- 2.49.0