【问题标题】:Reindex monthly indices into daily indices in Elasticsearch在 Elasticsearch 中将每月索引重新索引为每日索引
【发布时间】:2021-10-02 07:00:39
【问题描述】:

我有一些月度索引,例如 monthly-2021-01monthly-2021-02,其中包含带有日期字段的文档。

我想将这些月度指数分解为日度指数

以便将 1 月 1 日在 monthly-2021-01 中的文档存储在 daily-2021-01-1 中。

我尝试使用_reindex API,但找不到为重新索引的文档添加条件的方法。

【问题讨论】:

    标签: elasticsearch indexing reindex


    【解决方案1】:

    可以用

    {
            "source": {
                "index": "index-src",
                "query": {
                    "bool": {
                        "must": {
                            "range": {"date": {"gte": "start-date", "lt": "end-date"}},
                        }
                    }
                },
            },
            "dest": {
                "index": "index-dest"
            }
        }
    

    然后对每个 mont/date 关系执行此操作

    【讨论】:

    • 谨慎使用gt/lt,因为您可能会错过一些文件。更喜欢使用gte/lt
    猜你喜欢
    • 1970-01-01
    • 2018-11-17
    • 1970-01-01
    • 1970-01-01
    • 2015-08-03
    • 2021-08-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多