es delete index and create index

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:

  1. Delete index:
curl -u elastic:111111 -X DELETE "localhost:9200/user"
  1. 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:111111it 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.

Guess you like

Origin blog.csdn.net/u011197085/article/details/131519054