ElasticSearc创建索引报错:
{
"error": {
"root_cause": [
{
"type": "resource_already_exists_exception",
"reason": "index [shopping/rOncXIsQQjacZrKHNvDp8w] already exists",
"index_uuid": "rOncXIsQQjacZrKHNvDp8w",
"index": "shopping"
}
],
"type": "resource_already_exists_exception",
"reason": "index [shopping/rOncXIsQQjacZrKHNvDp8w] already exists",
"index_uuid": "rOncXIsQQjacZrKHNvDp8w",
"index": "shopping"
},
"status": 400
}
postman中报错:
可以参考:https://discuss.elastic.co/t/put-mapping-fails-index-already-exists-exception/56782
查看所有创建的索引(GET请求):
http://127.0.0.1:9200/_cat/indices?v
解决方案: 删掉index,重新创建index。
删除索引(DELETE请求):
http://127.0.0.1:9200/shopping
{
"acknowledged"【响应结果】: true, # true 操作成功
"shards_acknowledged"【分片结果】: true, # 分片操作成功
"index"【索引名称】: "shopping"
}
注意:创建索引库的分片数默认 1 片,在 7.0.0 之前的 Elasticsearch 版本中,默认 5 片
如果重复添加索引,会返回错误信息。
PUT具有幂等性!
第一次创建成功后,再去创建相同的就会出现问题!
如图所示,即为索引创建成功!