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

(-)a/Koha/BiblioUtils.pm (-2 lines)
Lines 131-138 sub get_all_biblios_iterator { Link Here
131
    if ($options{slice}) {
131
    if ($options{slice}) {
132
        $slice_count = $options{slice}->{count};
132
        $slice_count = $options{slice}->{count};
133
        $slice_modulo = $options{slice}->{index};
133
        $slice_modulo = $options{slice}->{index};
134
        $slice_modulo = 0 if ($slice_modulo == $slice_count);
135
136
        $search_terms = \[ ' mod(biblionumber, ?) = ?', $slice_count, $slice_modulo];
134
        $search_terms = \[ ' mod(biblionumber, ?) = ?', $slice_count, $slice_modulo];
137
    }
135
    }
138
136
(-)a/Koha/MetadataRecord/Authority.pm (-2 lines)
Lines 183-190 sub get_all_authorities_iterator { Link Here
183
    if ($options{slice}) {
183
    if ($options{slice}) {
184
        $slice_count = $options{slice}->{count};
184
        $slice_count = $options{slice}->{count};
185
        $slice_modulo = $options{slice}->{index};
185
        $slice_modulo = $options{slice}->{index};
186
        $slice_modulo = 0 if ($slice_modulo == $slice_count);
187
188
        $search_terms->{authid} = \[ ' mod ? = ?', $slice_count, $slice_modulo];
186
        $search_terms->{authid} = \[ ' mod ? = ?', $slice_count, $slice_modulo];
189
        $search_terms = {
187
        $search_terms = {
190
            '-and' => [
188
            '-and' => [
(-)a/misc/search_tools/rebuild_elastic_search.pl (-12 / +12 lines)
Lines 125-130 unless ($index_authorities || $index_biblios) { Link Here
125
    $index_authorities = $index_biblios = 1;
125
    $index_authorities = $index_biblios = 1;
126
}
126
}
127
127
128
if ($processes && @record_numbers) {
129
    die "Argument p|processes cannot be combined with bn|bnumber";
130
}
131
128
pod2usage(1) if $help;
132
pod2usage(1) if $help;
129
pod2usage( -exitstatus => 0, -verbose => 2 ) if $man;
133
pod2usage( -exitstatus => 0, -verbose => 2 ) if $man;
130
134
Lines 135-145 _verify_index_state($Koha::SearchEngine::Elasticsearch::AUTHORITIES_INDEX, $dele Link Here
135
139
136
my $slice_index = 0;
140
my $slice_index = 0;
137
my $slice_count = $processes // 1;
141
my $slice_count = $processes // 1;
142
my %iterator_options;
138
143
139
if ($slice_count > 1) {
144
if ($slice_count > 1) {
140
    # Fire up child processes for processing slices from 2 on. This main process will handle slice 1.
145
    # Fire up child processes for processing slices from 2 on. This main process will handle slice 1.
141
    $slice_index = 1;
146
    $slice_index = 0;
142
    for (my $proc = 2; $proc <= $processes; $proc++) {
147
    for (my $proc = 1; $proc < $slice_count; $proc++) {
143
        my $pid = fork();
148
        my $pid = fork();
144
        die "Failed to fork a child process\n" unless defined $pid;
149
        die "Failed to fork a child process\n" unless defined $pid;
145
        if ($pid == 0) {
150
        if ($pid == 0) {
Lines 149-160 if ($slice_count > 1) { Link Here
149
        }
154
        }
150
    }
155
    }
151
    # Fudge the commit count a bit to spread out the Elasticsearch commits
156
    # Fudge the commit count a bit to spread out the Elasticsearch commits
152
    $commit *= 1 + 0.10 * ($slice_index - 1);
157
    $commit *= 1 + 0.10 * $slice_index;
153
}
158
    _log(1, "Processing slice @{[$slice_index + 1]} of $slice_count\n");
154
155
my %iterator_options;
156
if ($slice_index) {
157
    _log(1, "Processing slice $slice_index of $slice_count\n");
158
    $iterator_options{slice} = { index => $slice_index, count => $slice_count };
159
    $iterator_options{slice} = { index => $slice_index, count => $slice_count };
159
}
160
}
160
161
Lines 193-208 if ($index_authorities) { Link Here
193
    _do_reindex($next, $Koha::SearchEngine::Elasticsearch::AUTHORITIES_INDEX);
194
    _do_reindex($next, $Koha::SearchEngine::Elasticsearch::AUTHORITIES_INDEX);
194
}
195
}
195
196
196
if ($slice_index == 1) {
197
if ($slice_index == 0) {
197
    # Main process, wait for children
198
    # Main process, wait for children
198
    for (my $proc = 2; $proc <= $processes; $proc++) {
199
    for (my $proc = 1; $proc < $processes; $proc++) {
199
        wait();
200
        wait();
200
    }
201
    }
201
}
202
}
202
203
203
=head2 _verify_index_state
204
=head2 _verify_index_state
204
205
205
    _                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       verify_index_state($Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX, 1);
206
    _verify_index_state($Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX, 1);
206
207
207
Checks the index state and recreates it if requested.
208
Checks the index state and recreates it if requested.
208
209
209
- 

Return to bug 21872