Skip to content

Instantly share code, notes, and snippets.

@jirrick
Created June 19, 2017 00:13
Show Gist options
  • Save jirrick/7b32a49c3205188ff931cfd9ea1caa2f to your computer and use it in GitHub Desktop.
Save jirrick/7b32a49c3205188ff931cfd9ea1caa2f to your computer and use it in GitHub Desktop.
reindex ES v1.7
#!/usr/bin/perl
#https://www.elastic.co/blog/changing-mapping-with-zero-downtime
use Search::Elasticsearch 2.03;
my $es = Search::Elasticsearch->new( nodes => '192.168.1.2:9200');
# Reindex docs:
my $bulk = $es->bulk_helper(
index => 'twitch_v2',
verbose => 1
);
$bulk->reindex( source => { index => 'twitch' },
transform => sub {
my $doc = shift;
# convert time from ss to ss.SSS (append milliseconds)
$doc->{_source}{timestamp} .= '.000';
#print $doc->{_source}{timestamp};
return $doc
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment