Re-indexing an index in ElasticSearch to change the number of shards

I need to change the number of shards in my index. The index is quite large and I may need to change the configuration 10-15 times for testing purposes before I am satisfied with the result. is there a tool that offers this functionality? or what's the easiest way to accomplish this?


source to share

1 answer

Both Perl and Ruby clients directly support reindexing.

In Perl, you would do:

my $source = $es->scrolled_search(
    index       => 'old_index',
    search_type => 'scan',
    scroll      => '5m',
    version     => 1

    source      => $source,
    dest_index  => 'new_index'


Find more information in Clinton Gormley's post .

In Ruby, you would do:

Tire.index('old').reindex 'new', settings: { number_of_shards: 3 }


Find more information in the relevant tire statement .