是时候用 ES 拯救发际线啦

ES批量插入可以使用别名插入吗

Elasticsearch | 作者 qyc | 发布于2018年11月19日 | 阅读数:4250

ES批量插入可以使用别名插入吗?是将api的index名写为索引别名就可以吗?
已邀请:

zz_hello

赞同来自:

应该是可以的,别名的使用和index应该是一样的

rochy - rochy_he

赞同来自:

不可以的,你可以实际操作下,无法通过别名进行插入

rochy - rochy_he

赞同来自:

一直都不可以吧,我在 2.X 试过不行,刚才试了 6.X 也不可以的,
 
直接报错:no write index is defined for alias [xxx]. The write index may be explicitly disabled using is_write_index=false or the alias points to multiple indices without one being designated as a write index"
 
看了官方的解释:
Only one index per alias can be assigned to be the write index at a time. If no write index is specified and there are multiple indices referenced by an alias, then writes will not be allowed.(也就是说同时只能有一个索引可以被写入,而且需要手动设置)
 
POST /_aliases
{
"actions" : [
{
"add" : {
"index" : "test",
"alias" : "alias1",
"is_write_index" : true
}
}
]
}

要回复问题请先登录注册