Removing Data From ElasticSearch
If you ever need to delete all the indexes, this may come in handy:
curl -X DELETE 'http://localhost:9200/_all'
Powershell:
Invoke-WebRequest -method DELETE http://localhost:9200/_all
You can delete using cURL
or visually using one of the many tools that open source enthusiasts have created for Elasticsearch.
Using cURL
curl -XDELETE localhost:9200/index/type/documentID
e.g.
curl -XDELETE localhost:9200/shop/product/1
You will then receive a reply as to whether this was successful or not. You can delete an entire index or types with an index also, you can delete a type by leaving out the document ID like so -
curl -XDELETE localhost:9200/shop/product
If you wish to delete an index -
curl -XDELETE localhost:9200/shop
If you wish to delete more than one index that follows a certain naming convention (note the *
, a wildcard), -
curl -XDELETE localhost:9200/.mar*
Visually
There are various tools as mentioned above, I wont list them here but I will link you to one which enables you to get started straight away, located here. This tool is called KOPF, to connect to your host please click on the logo on top left hand corner and enter the URL of your cluster.
Once connected you will be able to administer your entire cluster, delete, optimise and tune your cluster.
You have to send a DELETE
request to
http://[your_host]:9200/[your_index_name_here]
You can also delete a single document:
http://[your_host]:9200/[your_index_name_here]/[your_type_here]/[your_doc_id]
I suggest you to use elastichammer.
After deleting you can look up if the index still exists with the following URL: http://[your_host]:9200/_stats/
Good luck!
The documentation (or The Definitive Guide) says, that you can also use the next query to delete all indices:
curl -XDELETE 'http://localhost:9200/*'
And there's an important note:
For some, the ability to delete all your data with a single command is a very scary prospect. If you want to eliminate the possibility of an accidental mass-deletion, you can set the following to
true
in yourelasticsearch.yml
:
action.destructive_requires_name: true