Created
June 19, 2017 00:13
-
-
Save jirrick/7b32a49c3205188ff931cfd9ea1caa2f to your computer and use it in GitHub Desktop.
reindex ES v1.7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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