为什么这个错误发生 #
unavailable_shards_exception 表示所需的分片数量不可用,无法执行操作。
如何修复 #
1. 检查分片状态 #
GET /_cat/shards?v
2. 等待分片恢复 #
GET /_cluster/health?wait_for_active_shards=all
3. 调整副本设置 #
PUT /<index>/_settings
{
"index": {
"number_of_replicas": 0
}
}
4. 使用 wait_for_active_shards #
POST /<index>/_doc/<id>?wait_for_active_shards=1
预防措施 #
- 确保有足够的节点
- 配置合理的副本数
- 监控分片健康





