如果你的 Elasticsearch 集群有密码,你需要在 curl 命令中提供用户名和密码。以下是你应该怎么做的:
- 删除索引:
curl -u elastic:111111 -X DELETE "localhost:9200/user"
- 重新创建索引以及相应的映射:
curl -u elastic:111111 -X PUT "localhost:9200/user" -H 'Content-Type: application/json' -d'
{
"mappings": {
"properties": {
"id": { "type": "integer" },
"name": { "type": "text" },
"role_id": { "type": "integer" },
"c_time": { "type": "date", "format": "strict_date_optional_time||epoch_millis" }
}
}
}
'
在这里,-u elastic:111111
是用来提供用户名和密码的。将其替换为你实际的用户名和密码。同样,“localhost:9200” 是你的 Elasticsearch 实例的地址,你需要将其替换为实际的地址。