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

Return to bug 21872