Lines 30-36
B<compare_es_to_db.pl>
Link Here
|
30 |
=cut |
30 |
=cut |
31 |
|
31 |
|
32 |
use Modern::Perl; |
32 |
use Modern::Perl; |
33 |
use Array::Utils qw( array_diff ); |
33 |
use Array::Utils qw( array_minus ); |
34 |
|
34 |
|
35 |
use C4::Context; |
35 |
use C4::Context; |
36 |
|
36 |
|
Lines 76-104
foreach my $index ( ('biblios','authorities') ){
Link Here
|
76 |
push @es_ids, $doc->{_id}; |
76 |
push @es_ids, $doc->{_id}; |
77 |
$i++; |
77 |
$i++; |
78 |
} |
78 |
} |
79 |
print "\nComparing arrays, this may take a while\n"; |
|
|
80 |
|
81 |
# And compare the arrays |
82 |
# array_diff returns only a list of values which are not common to both arrays |
83 |
my @diff = array_diff(@db_records, @es_ids ); |
84 |
|
85 |
print "All records match\n" unless @diff; |
86 |
|
79 |
|
87 |
# Fetch values for providing record links |
80 |
# Fetch values for providing record links |
88 |
my $es_params = $searcher->get_elasticsearch_params; |
81 |
my $es_params = $searcher->get_elasticsearch_params; |
89 |
my $es_base = "$es_params->{nodes}[0]/$es_params->{index_name}"; |
82 |
my $es_base = "$es_params->{nodes}[0]/$es_params->{index_name}"; |
90 |
my $opac_base = C4::Context->preference('OPACBaseURL'); |
83 |
my $opac_base = C4::Context->preference('OPACBaseURL'); |
91 |
|
84 |
|
|
|
85 |
print "\nComparing arrays, this may take a while\n"; |
86 |
|
87 |
my @koha_problems = sort { $a <=> $b } array_minus(@db_records, @es_ids); |
88 |
my @es_problems = sort { $a <=> $b } array_minus(@es_ids, @db_records); |
92 |
|
89 |
|
93 |
my @koha_problems; |
90 |
print "All records match\n" unless ( @koha_problems || @es_problems ); |
94 |
my @es_problems; |
|
|
95 |
foreach my $problem ( sort { $a <=> $b } @diff){ |
96 |
if ( (grep /^$problem$/, @db_records) ){ |
97 |
push @koha_problems, $problem; |
98 |
} else { |
99 |
push @es_problems, $problem; |
100 |
} |
101 |
} |
102 |
|
91 |
|
103 |
if ( @koha_problems ){ |
92 |
if ( @koha_problems ){ |
104 |
print "=================\n"; |
93 |
print "=================\n"; |
Lines 113-118
foreach my $index ( ('biblios','authorities') ){
Link Here
|
113 |
} |
102 |
} |
114 |
} |
103 |
} |
115 |
} |
104 |
} |
|
|
105 |
|
116 |
if ( @es_problems ){ |
106 |
if ( @es_problems ){ |
117 |
print "=================\n"; |
107 |
print "=================\n"; |
118 |
print "Records that exist in ES but not in Koha\n"; |
108 |
print "Records that exist in ES but not in Koha\n"; |
119 |
- |
|
|