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

(-)a/Koha/BiblioUtils.pm (-3 / +11 lines)
Lines 111-121 The iterator is a Koha::MetadataIterator object. Link Here
111
=cut
111
=cut
112
112
113
sub get_all_biblios_iterator {
113
sub get_all_biblios_iterator {
114
    my ( @biblionumbers ) = @_;
114
    my $database = Koha::Database->new();
115
    my $database = Koha::Database->new();
115
    my $schema   = $database->schema();
116
    my $schema   = $database->schema();
116
    my $rs =
117
    my $rs = $schema->resultset('Biblio')->search(
117
      $schema->resultset('Biblio')->search( {},
118
        {
118
        { columns => [qw/ biblionumber /] } );
119
            (
120
                @biblionumbers
121
                ? ( biblionumber => { -in => \@biblionumbers } )
122
                : ()
123
            )
124
        },
125
        { columns => [qw/ biblionumber /] }
126
    );
119
    my $next_func = sub {
127
    my $next_func = sub {
120
        # Warn and skip bad records, otherwise we break the loop
128
        # Warn and skip bad records, otherwise we break the loop
121
        while (1) {
129
        while (1) {
(-)a/Koha/MetadataRecord/Authority.pm (-3 / +8 lines)
Lines 167-177 The iterator is a Koha::MetadataIterator object. Link Here
167
=cut
167
=cut
168
168
169
sub get_all_authorities_iterator {
169
sub get_all_authorities_iterator {
170
    my ( @authid ) = @_;
170
    my $database = Koha::Database->new();
171
    my $database = Koha::Database->new();
171
    my $schema   = $database->schema();
172
    my $schema   = $database->schema();
172
    my $rs =
173
    my $rs = $schema->resultset('AuthHeader')->search(
173
      $schema->resultset('AuthHeader')->search( { marcxml => { '!=', undef } },
174
        {
174
        { columns => [qw/ authid authtypecode marcxml /] } );
175
            marcxml => { '!=', undef },
176
            ( @authid ? ( authid => { -in => \@authid } ) : () )
177
        },
178
        { columns => [qw/ authid authtypecode marcxml /] }
179
    );
175
    my $next_func = sub {
180
    my $next_func = sub {
176
        my $row = $rs->next();
181
        my $row = $rs->next();
177
        return if !$row;
182
        return if !$row;
(-)a/misc/search_tools/rebuild_elastic_search.pl (-26 / +8 lines)
Lines 124-158 sanity_check(); Link Here
124
my $next;
124
my $next;
125
if ($index_biblios) {
125
if ($index_biblios) {
126
    _log(1, "Indexing biblios\n");
126
    _log(1, "Indexing biblios\n");
127
    if (@biblionumbers) {
127
    my $records = Koha::BiblioUtils->get_all_biblios_iterator( @biblionumbers );
128
        $next = sub {
128
    $next = sub {
129
            my $r = shift @biblionumbers;
129
        $records->next();
130
            return () unless defined $r;
130
    };
131
            return ($r, Koha::BiblioUtils->get_from_biblionumber($r, item_data => 1 ));
132
        };
133
    } else {
134
        my $records = Koha::BiblioUtils->get_all_biblios_iterator();
135
        $next = sub {
136
            $records->next();
137
        }
138
    }
139
    do_reindex($next, $Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX);
131
    do_reindex($next, $Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX);
140
}
132
}
141
if ($index_authorities) {
133
if ($index_authorities) {
142
    _log(1, "Indexing authorities\n");
134
    _log(1, "Indexing authorities\n");
143
    if (@biblionumbers) {
135
    my $records = Koha::MetadataRecord::Authority->get_all_authorities_iterator( @biblionumbers );
144
        $next = sub {
136
    $next = sub {
145
            my $r = shift @biblionumbers;
137
        $records->next();
146
            return () unless defined $r;
138
    };
147
            my $a = Koha::MetadataRecord::Authority->get_from_authid($r);
148
            return ($r, $a->record);
149
        };
150
    } else {
151
        my $records = Koha::MetadataRecord::Authority->get_all_authorities_iterator();
152
        $next = sub {
153
            $records->next();
154
        }
155
    }
156
    do_reindex($next, $Koha::SearchEngine::Elasticsearch::AUTHORITIES_INDEX);
139
    do_reindex($next, $Koha::SearchEngine::Elasticsearch::AUTHORITIES_INDEX);
157
}
140
}
158
141
159
- 

Return to bug 18130