View | Details | Raw Unified | Return to bug 22831
Collapse All | Expand All

(-)a/misc/maintenance/compare_es_to_db.pl (-6 / +14 lines)
Lines 30-41 B<compare_es_to_db.pl> Link Here
30
=cut
30
=cut
31
31
32
use Modern::Perl;
32
use Modern::Perl;
33
use Koha::Items;
34
use Koha::SearchEngine::Elasticsearch;
35
use Array::Utils qw( array_diff );
33
use Array::Utils qw( array_diff );
36
34
37
use Koha::Biblios;
35
use C4::Context;
36
38
use Koha::Authorities;
37
use Koha::Authorities;
38
use Koha::Biblios;
39
use Koha::Items;
40
use Koha::SearchEngine::Elasticsearch;
39
41
40
foreach my $index ( ('biblios','authorities') ){
42
foreach my $index ( ('biblios','authorities') ){
41
    print "=================\n";
43
    print "=================\n";
Lines 67-73 foreach my $index ( ('biblios','authorities') ){ Link Here
67
    print "Fetching Elasticsearch records ids";
69
    print "Fetching Elasticsearch records ids";
68
    while (my $doc = $scroll->next ){
70
    while (my $doc = $scroll->next ){
69
        print "." if !($i % 500);
71
        print "." if !($i % 500);
70
        print "\nFetching next 5000" if !($i % 5000);
72
        print "\n$i records retrieved" if !($i % 5000);
71
        push @es_ids, $doc->{_id};
73
        push @es_ids, $doc->{_id};
72
        $i++;
74
        $i++;
73
    }
75
    }
Lines 77-82 foreach my $index ( ('biblios','authorities') ){ Link Here
77
    my @diff = array_diff(@db_records, @es_ids );
79
    my @diff = array_diff(@db_records, @es_ids );
78
    print "All records match\n" unless @diff;
80
    print "All records match\n" unless @diff;
79
    foreach my $problem (@diff){
81
    foreach my $problem (@diff){
80
        print "Record #$problem is not in both sources\n";
82
        if ( (grep $problem, @db_records) && 0){
83
            print "Record $problem exists in Koha but not ES\n";
84
            print "  Visit here to see record: ".C4::Context->preference('OPACBaseURL')."/cgi-bin/koha/opac-detail.pl?biblionumber=".$problem."\n";
85
        } else {
86
            print "Record $problem exists in ES but not Koha\n";
87
            my $es_params = $searcher->get_elasticsearch_params;
88
            print "  Enter this command to view record: curl $es_params->{nodes}[0]/$es_params->{index_name}/data/$problem?pretty=true\n";
89
        }
81
    }
90
    }
82
}
91
}
83
- 

Return to bug 22831