From 59d37526aeff35c14c1b92d94a1a42a192d9dbdd Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 6 Nov 2019 14:37:01 +0000 Subject: [PATCH] Bug 22831: (follow-up) Determine where the record is missing and provide link, show counter --- misc/maintenance/compare_es_to_db.pl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/misc/maintenance/compare_es_to_db.pl b/misc/maintenance/compare_es_to_db.pl index 9fab08a759..c35b5214d0 100644 --- a/misc/maintenance/compare_es_to_db.pl +++ b/misc/maintenance/compare_es_to_db.pl @@ -30,12 +30,14 @@ B =cut use Modern::Perl; -use Koha::Items; -use Koha::SearchEngine::Elasticsearch; use Array::Utils qw( array_diff ); -use Koha::Biblios; +use C4::Context; + use Koha::Authorities; +use Koha::Biblios; +use Koha::Items; +use Koha::SearchEngine::Elasticsearch; foreach my $index ( ('biblios','authorities') ){ print "=================\n"; @@ -67,7 +69,7 @@ foreach my $index ( ('biblios','authorities') ){ print "Fetching Elasticsearch records ids"; while (my $doc = $scroll->next ){ print "." if !($i % 500); - print "\nFetching next 5000" if !($i % 5000); + print "\n$i records retrieved" if !($i % 5000); push @es_ids, $doc->{_id}; $i++; } @@ -77,6 +79,13 @@ foreach my $index ( ('biblios','authorities') ){ my @diff = array_diff(@db_records, @es_ids ); print "All records match\n" unless @diff; foreach my $problem (@diff){ - print "Record #$problem is not in both sources\n"; + if ( (grep $problem, @db_records) && 0){ + print "Record $problem exists in Koha but not ES\n"; + print " Visit here to see record: ".C4::Context->preference('OPACBaseURL')."/cgi-bin/koha/opac-detail.pl?biblionumber=".$problem."\n"; + } else { + print "Record $problem exists in ES but not Koha\n"; + my $es_params = $searcher->get_elasticsearch_params; + print " Enter this command to view record: curl $es_params->{nodes}[0]/$es_params->{index_name}/data/$problem?pretty=true\n"; + } } } -- 2.11.0