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

(-)a/C4/Installer/PerlDependencies.pm (+4 lines)
Lines 917-922 our $PERL_DEPS = { Link Here
917
        'usage'    => 'Z39.50 responder',
917
        'usage'    => 'Z39.50 responder',
918
        'required' => '0',
918
        'required' => '0',
919
        'min_ver'  => '1.15',
919
        'min_ver'  => '1.15',
920
    'Array::Utils' => {
921
        usage    => 'Elasticsearch integration',
922
        required => '0',
923
        min_ver  => '0.5',
920
    },
924
    },
921
};
925
};
922
926
(-)a/misc/maintenance/compare_es_to_db.pl (-1 / +76 lines)
Line 0 Link Here
0
- 
1
#! /usr/bin/perl
2
#
3
# This compares record counts from a Koha database to elastic search
4
5
# Copyright 2019 ByWater Solutions
6
#
7
# This file is part of Koha.
8
#
9
# Koha is free software; you can redistribute it and/or modify it under the
10
# terms of the GNU General Public License as published by the Free Software
11
# Foundation; either version 3 of the License, or (at your option) any later
12
# version.
13
#
14
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License along
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22
=head1 NAME
23
24
compare_es_to_db.pl - compares record counts from a Koha database to Elasticsearch
25
26
=head1 SYNOPSIS
27
28
B<compare_es_to_db.pl>
29
30
=cut
31
32
use Modern::Perl;
33
use Koha::Items;
34
use Koha::SearchEngine::Elasticsearch;
35
use Array::Utils qw( array_diff );
36
37
use Koha::Biblios;
38
use Koha::Authorities;
39
40
foreach my $index ( ('biblios','authorities') ){
41
    print "=================\n";
42
    print "Checking $index\n";
43
    my @db_records = $index eq 'biblios' ? Koha::Biblios->search()->get_column('biblionumber') : Koha::Authorities->search()->get_column('authid');
44
45
    my $searcher = Koha::SearchEngine::Elasticsearch->new({ index => $index });
46
    my $es = $searcher->get_elasticsearch();
47
    my $count = $es->indices->stats( index => $searcher->get_elasticsearch_params->{index_name} )
48
        ->{_all}{primaries}{docs}{count};
49
    print "Count in db for $index is " . scalar @db_records . ", count in Elasticsearch is $count\n";
50
    # All done if they match
51
    next if @db_records == $count;
52
53
    # Otherwise, lets find all the ES ids
54
    my $scroll = $es->scroll_helper(
55
        index => $searcher->get_elasticsearch_params->{index_name},
56
        size => 5000,
57
        body => {
58
            query => {
59
                match_all => {}
60
            }
61
        },
62
        scroll_in_qs => 1,
63
    );
64
65
    my @es_ids;
66
67
    while (my $doc = $scroll->next ){
68
        push @es_ids, $doc->{_id};
69
    }
70
71
    # And compare the arrays
72
    my @diff = array_diff(@db_records, @es_ids );
73
    foreach my $problem (@diff){
74
        print "Record #$problem is not in both sources\n";
75
    }
76
}

Return to bug 22831