【问题标题】:Re-indexing an index in ElasticSearch to change the number of shards在 ElasticSearch 中重新索引索引以更改分片数
【发布时间】:2012-04-14 01:45:50
【问题描述】:

我需要更改索引中的分片数量。该索引相当大,我可能必须更改配置 10-15 次以进行测试,然后才能对结果感到满意。是否有开箱即用的工具提供这种功能?或者最简单的方法是什么?

【问题讨论】:

    标签: indexing elasticsearch


    【解决方案1】:

    PerlRuby 客户端都直接支持重新索引。

    在 Perl 中,你会这样做:

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

    post by Clinton Gormley 中查找更多信息。

    在 Ruby 中,你会这样做:

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

    relevant Tire commit 中查找更多信息。

    【讨论】:

    • +1 作为答案和出色的工作;)我要补充一点,另一种选择是从数据库的内容中重新索引。如果您要更改索引的内容,例如添加要索引的新字段,这也很常见。
    • 有没有办法从 python 做到这一点?
    猜你喜欢
    • 1970-01-01
    • 2020-07-26
    • 2021-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-10
    • 2023-02-02
    相关资源
    最近更新 更多