If your Elasticsearch cluster has a password, you need to provide the username and password in the curl command. Here's what you should do:
- Delete index:
curl -u elastic:111111 -X DELETE "localhost:9200/user"
- Recreate the index and corresponding mapping:
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" }
}
}
}
'
Here, -u elastic:111111
it is used to provide username and password. Replace this with your actual username and password. Again, "localhost:9200" is the address of your Elasticsearch instance, you need to replace it with your actual address.