是否可以使用ElasticSearch别名写入多个索引? [英] Is it possible to write to multiple indexes with an ElasticSearch alias?

查看:4266
本文介绍了是否可以使用ElasticSearch别名写入多个索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ElasticSearch文档内容如下:


别名也可以映射到多个索引,指定时,别名将自动扩展到别名索引。 / p>

但是当我尝试添加一个别名到2个索引并写入这两个,似乎没有更新与文档。如果我删除其中一个别名,它将正确写入仍然存在的别名。



无法写入多个写入别名:

  $ curl -XGET'http:// localhost:9200 / _aliases'

结果:

  {
dev_01:{
aliases :{
dev_read:{},
dev_write:{}
}
},
dev:{
aliases :{
dev_write:{}
}
}
}

适用于单个别名:

  $ curl -XGET'http:// localhost:9200 / _aliases '

结果:

  {
dev_01:{
aliases:{
dev_read:{},
dev_write:{}
}
},
dev:{
aliases:{}
}
}

弹性搜索是否支持写入多个索引?如果指向多个索引,别名是只读的?

解决方案

答案是否



所以看来我应该把这个哔哔声分析得更深,但是我的客户端从es得到的响应是:


ElasticSearchIllegalArgumentException [Alias [dev_write]有多个与之相关联的索引[[dev_01,dev]],无法执行单个索引op


只是希望文档有一点更明确的前面,因为他们困惑了我一点点

起初似乎意味着你可以:


索引别名API允许使用名称来别名索引,所有 API会自动将别名转换为实际的索引名称。别名也可以映射到多个索引...



将别名与多个索引相关联只是几个添加操作...


进一步的页面让你知道你不能:


索引到指向多个索引的别名是一个错误。



The ElasticSearch Docs reads:

An alias can also be mapped to more than one index, and when specifying it, the alias will automatically expand to the aliases indices.

But when I try to add an alias to 2 indices and write to both, neither seem to get updated with the document. If I remove one of the aliases, it will write correctly to the alias that still exists.

Fails with multiple write aliases:

$ curl -XGET 'http://localhost:9200/_aliases'

result:

{
  "dev_01": {
    "aliases": {
      "dev_read": {},
      "dev_write": {}
    }
  },
  "dev": {
    "aliases": {
      "dev_write": {}
    }
  }
}

Works with single alias:

$ curl -XGET 'http://localhost:9200/_aliases'

result:

{
  "dev_01": {
    "aliases": {
      "dev_read": {},
      "dev_write": {}
    }
  },
  "dev": {
    "aliases": {}
  }
}

Does elasticsearch support writing to multiple indices? Are aliases Read-Only if pointed at multiple indices?

解决方案

the answer is No

So it appears I should have triaged this a beep deeper, but the response my client gets from es is:

ElasticSearchIllegalArgumentException[Alias [dev_write] has more than one indices associated with it [[dev_01, dev]], can't execute a single index op

Just wish the docs were a little more explicit up front, as they confused me a bit

At first seems to imply you can:

The index aliases API allow to alias an index with a name, with all APIs automatically converting the alias name to the actual index name. An alias can also be mapped to more than one index...

Associating an alias with more than one index are simply several add actions...

Further down the page lets you know you can not:

It is an error to index to an alias which points to more than one index.

这篇关于是否可以使用ElasticSearch别名写入多个索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆