- 前言
- 原因分析
- 解决方法(二选一)
- 1、指定具体索引名
- 2、继续使用别名
前言转载请标明出处:
https://bigmaning.blog.csdn.net/article/details/121578814
本文出自:【BigManing的博客】
执行es操作报错
no write index is defined for alias [log]. 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原因分析
log 是自定义的索引别名,泛指符合log-*模式的索引,例如log-20211212 ,在搜索时可以不用指定具体的索引 ,方便全局搜索。
但是写入操作数据时 不用直接使用别名[log] ,否则就会报错(如上)
解决方法(二选一) 1、指定具体索引名例如写入操作时,指定具体的索引名
2、继续使用别名这种情况下,需要指定一个索引为可写,例如把log-20211212设置为可写索引。
POST /_aliases
{
"actions" : [
{
"add" : {
"index" : "log-20211212",
"alias" : "log",
"is_write_index" : true
}
}
]
}


![Elasticsearch - no write index is defined for alias [log]报错原因以及解决就办法 Elasticsearch - no write index is defined for alias [log]报错原因以及解决就办法](http://www.mshxw.com/aiimages/31/612405.png)
