The following tests are available in elastic search version 5.6.10.
First of all, ElasticSearch does not support deleting a type since 2.x, so when you use the delete command to try to delete a type, you will get the following error:
No handler found for uri [/dating_profile/zhenai/] and method [DELETE]
test
If there is an index named dating "profile and a type named zhenai:
curl -XDELETE http://192.168.1.102:9200/dating_profile/zhenai
Errors are reported after execution as follows:
So now if you want to delete type, you have two options:
***1. * * * reset index.
***2. * * delete all data under type.
If you reset the index, the official recommendation is:
https://www.elastic.co/guide/en/elasticsearch/reference/5.4/indices-delete-mapping.html
Delete Mapping It is no longer possible to delete the mapping for a type. Instead you should delete the index and recreate it with the new mappings.
Delete index
Delete the index named dating "profile as follows:
curl -XDELETE http://192.168.1.102:9200/dating_profile/
Delete succeeded, return value is:
{ "acknowledged": true }
Delete all data under type
If you want to delete all data content of type zhenai at one time, please refer to the official document:
https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-delete-by-query.html
It is mentioned that you can restrict to a single type through delete by query. As follows, it will only delete all the data with the index as dating and the type as zhenai under profile:
curl -X POST "http://192.168.1.102:9200/dating_profile/zhenai/_delete_by_query?conflicts=proceed" -H 'Content-Type: application/json' -d' { "query": { "match_all": {} } }'
The deletion succeeded. The return value is as follows:
{ "took": 78, "timed_out": false, "total": 107, "deleted": 107, "batches": 1, "version_conflicts": 0, "noops": 0, "retries": { "bulk": 0, "search": 0 }, "throttled_millis": 0, "requests_per_second": -1.0, "throttled_until_millis": 0, "failures": [] }
You can also delete multiple documents under index and multiple types at one time, as follows: delete the data with the type of zhenai under the index of dating profile, and delete the data with the type of movie under the index of movies.
curl -X POST "http://192.168.1.102:9200/dating_profile,movies/zhenai,movie/_delete_by_query" -H 'Content-Type: application/json' -d' { "query": { "match_all": {} } } '
The return value is as follows:
{ "took": 93, "timed_out": false, "total": 61, "deleted": 61, "batches": 1, "version_conflicts": 0, "noops": 0, "retries": { "bulk": 0, "search": 0 }, "throttled_millis": 0, "requests_per_second": -1.0, "throttled_until_millis": 0, "failures": [] }
Digression
5. Reindex provided by xes can directly reconstruct the data in the search cluster. You can modify mapping directly as follows.
Change the index to dating profile to new dating profile as follows
curl -XPOST "http://192.168.1.102:9200/_reindex?pretty" -H 'Content-Type: application/json' -d' { "source": { "index": "dating_profile" }, "dest": { "index": "new_dating_profile" } } '
After this operation, the old index still exists. The old data can be found in the dating profile and the new dating profile.
A full set of video tutorials and other related learning resources of ElasticSearch + ELK log platform can be obtained by replying [1] and adding a small assistant in the public account background.
This public account is free * * to provide csdn download service and massive it learning resources * * if you are ready to enter the IT pit and aspire to become an excellent program ape, these resources are suitable for you, including but not limited to java, go, python, springcloud, elk, embedded, big data, interview materials, front-end and other resources. At the same time, we have set up a technology exchange group. There are many big guys who will share technology articles from time to time. If you want to learn and improve together, you can reply [2] in the background of the public account. Free invitation plus technology exchange groups will learn from each other and share programming it related resources from time to time.
Scan the code to pay attention to the wonderful content and push it to you at the first time