3

I am trying to delete all document from my index and getting the following error on CURL. No handler found for uri [/logstash-2016.03.11/logevent/] and method [DELETE]

Here is my delete command on Windows command.

curl -XDELETE "http://localhost:9200/logstash-2016.03.11/logevent/"

can anybody help?

Val
  • 207,596
  • 13
  • 358
  • 360
Fahad Ahmed
  • 63
  • 1
  • 1
  • 6
  • This should help: http://stackoverflow.com/questions/34286357/delete-all-documents-of-a-type-in-elasticsearch-2-1/34286459#34286459 – Val Mar 12 '16 at 04:18
  • Possible duplicate of [Delete all documents from index/type without deleting type](https://stackoverflow.com/questions/23917327/delete-all-documents-from-index-type-without-deleting-type) – j0k Jul 31 '17 at 15:49

2 Answers2

7
curl -XPOST "http://localhost:9200/logstash2016.03.11/logevent/_delete_by_query" -d'
{
     "query":{
          "match_all":{}
      }
}'

The delete-by-query API is new and should still be considered experimental. The API may change in ways that are not backwards compatible

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html

Ajay Singh
  • 1,251
  • 14
  • 17
3

You cannot delete a type from an index by executing a delete on the type.

To solve your problem, you have 2 solutions.

  1. If you only have a single type in your logstash index, just execute curl -XDELETE "http://localhost:9200/logstash-2016.03.11. It will delete the old index, but logstash will recreate it when it'll process the next event

  2. You install the delete by query plugin ( https://www.elastic.co/guide/en/elasticsearch/plugins/2.2/plugins-delete-by-query.html ) and run something like this :

    curl -XDELETE /logstash-2016.03.11/logevent/_query -d '
    {
      "query": { "match_all": {}}
    }'
    
maximede
  • 1,763
  • 14
  • 24
  • Thanks for you help. Is there a good way to pass curl commands on windows. I use the command shell but typing the multi-line CURL commands is a pain there. – Fahad Ahmed Mar 14 '16 at 18:30
  • Sorry I don't use Windows, but I guess you could put everything on a single line. ```curl -XDELETE /logstash-2016.03.11/logevent/_query -d '{"query": {"match_all": {}}}'``` . Also, would you mind accepting the answer if it worked for you ? – maximede Mar 14 '16 at 18:42