【问题标题】:2 indexes with same alias but only one is marked as write index2 个具有相同别名但只有一个被标记为写入索引的索引
【发布时间】:2021-05-02 00:25:38
【问题描述】:

我在弹性搜索中有 2 个索引具有相同的别名,但仅针对其中一个,is_write_index 为真。现在,当我尝试按别名写入索引时,出现以下错误:

Alias [alias_name] has more than one indices associated with it [[indexname1, indexname2]], can't execute a single index op

这是我正在做但失败的事情:

  let doc = {
      script: {
        source: ...,
        lang: "painless",
        params: {
          ...document
        }
      },
      upsert: {
        ...document
      }
    };
   await client.update({
    index: alias_name,
    id: docId,
    body: doc
  });

这可能是什么问题?我的想法是,如果只有其中一个被标记为写入索引,它只会写入该索引并且写入不应该失败(https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html#aliases-write-index)。我理解错了吗?

【问题讨论】:

标签: elasticsearch


【解决方案1】:

问题在于更新是combo operation,其中首先使用 GET 检索文档,然后使用脚本进行更新,最后使用索引操作重新索引。

在您的情况下不起作用的是第一个操作,因为 GET 不能通过跨越多个索引的别名完成,即使其中只有一个作为 is_write_index 标志设置为 true,也不能保证文档要更新的实际上是在那个索引中。

【讨论】:

    猜你喜欢
    • 2015-06-01
    • 2015-12-06
    • 1970-01-01
    • 1970-01-01
    • 2020-11-02
    • 2012-02-29
    • 1970-01-01
    • 2016-04-01
    • 2017-09-08
    相关资源
    最近更新 更多