Skip to content

Instantly share code, notes, and snippets.

@diegok
Created May 21, 2013 14:38
Show Gist options
  • Save diegok/5620312 to your computer and use it in GitHub Desktop.
Save diegok/5620312 to your computer and use it in GitHub Desktop.
sub rebuild_hot {
my $ns = shift;
my $new_index = 'ss_' . time;
say "New index will be '$new_index'" if $c->opt->verbose;
my $old_index = eval { my $cur_index = (keys %{$ns->alias->aliased_to} )[0] };
warn $@ if $@;
$ns->index($new_index)->create;
my $domain;
if ( $old_index ) {
$domain = 'temp';
$ns->alias($domain)->to( $old_index ) ;
$ns->alias($domain)->to( $new_index );
}
else {
$domain = $new_index;
$ns->alias->to( $new_index );
}
full_index( $c->search_model->domain($domain) );
if ( $old_index ) {
$ns->alias->to( $new_index );
say "Removing old index '$old_index'" if $c->opt->verbose;
$ns->index($old_index)->delete.
}
say 'Done.' if $c->opt->verbose;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment