【问题标题】:ElasticSearch: reindex and aliases (keep routing policy)ElasticSearch:重新索引和别名(保持路由策略)
【发布时间】:2017-05-17 14:57:40
【问题描述】:

我为每个用户使用别名。对于每个别名,我都链接了一个 routing 和一个 filter

PUT _/<index>/_alias/u1@u1.com'
{
  "routing": "u1@u1.com",
  "filter": {
    "term": {
      "user": "u1@u1.com"
    }
  }
}

所以,我设置索引和搜索使用routing 信息。

我想使用_reindex api 重新索引另一个索引上的所有文档。创建新索引后,我创建了所有别名。因此,我发现必须使用别名重新索引文档才能保持路由策略。

有没有办法在_reindex上设置它?

例子:

POST _/_reindex
{
  "source": {
    "index": "old"
  },
  "dest": {
    "index": "new"
  }
}
'

有什么想法吗?

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    是的,您可以:

    POST _reindex
    {
      "source": {
        "index": "old",
        "query": {
          "term": {
            "user": "u1@u1.com"
          }
        }
      },
      "dest": {
        "index": "new",
        "routing": "=u1@u1.com"
      }
    }
    

    【讨论】:

    • 你能看看我的回答吗?
    【解决方案2】:

    根据this documentation

    默认情况下,如果_reindex 看到一个带有路由的文档,那么除非脚本更改它,否则该路由将被保留。

    所以,就我而言,默认情况下,对于每个已经具有 routing 信息的文档,它都被保留了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多