Skip to content

Commit

Permalink
Script/Author: use bulk_helper from Search::Elasticsearch instead of …
Browse files Browse the repository at this point in the history
…the model.
  • Loading branch information
mickeyn committed Apr 25, 2017
1 parent ee4e7c4 commit b6f5c70
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/MetaCPAN/Script/Author.pm
Expand Up @@ -61,7 +61,12 @@ sub index_authors {
} map { $_->{_source} } @{ $dates->{hits}->{hits} }
};

my $bulk = $self->model->bulk( size => 100 );
my $bulk = $self->es->bulk_helper(
index => $self->index->name,
type => 'author',
max_count => 250,
timeout => '25m',
);

my @author_ids_to_purge;

Expand Down Expand Up @@ -127,8 +132,13 @@ sub index_authors {
push @author_ids_to_purge, $put->{pauseid};

# Only try put if this is a valid format
$bulk->put($author);
$bulk->update({
id => $pauseid,
doc => $put,
doc_as_upsert => 1,
});
}
$bulk->flush;
$self->index->refresh;

$self->purge_author_key(@author_ids_to_purge);
Expand Down Expand Up @@ -175,7 +185,7 @@ sub author_config {
= { map { $_ => $author->{$_} }
qw(name asciiname profile blog perlmongers donation email website city region country location extra)
};
$author->{updated} = $mtime;
$author->{updated} = $mtime->strftime('%Y-%m-%dT%H:%M:%S');
return $author;
}

Expand Down

0 comments on commit b6f5c70

Please sign in to comment.