Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DELETE all documents of a type in ElasticSearch 2.x

I've updated ElasticSearch to 2.1 version.

Before of that, I deleted every document in a type using:

curl -XDELETE '<server_node>:<port>/<index>/<type>' -i
curl -XDELETE 'http://ESNode01:9201/living/inputs' -i

From now then, this is the response:

HTTP/1.1 400 Bad Request Content-Type: text/plain; charset=UTF-8

Content-Length: 61

No handler found for uri [/living/inputs] and method [DELETE]

What am I doing wrong?

like image 383
Jordi Avatar asked Dec 15 '15 10:12

Jordi


People also ask

How do I delete all files in Elasticsearch?

Elasticsearch provides _delete_by_query REST API to delete multiple documents based on a specified query, Here we need to pass JSON as the request body with POST method, It will delete those document which fulfills by specified query.

How do I delete a type in Elasticsearch?

You can use _delete_by_query path to delete type. Save this answer.

Does deleting index delete documents Elasticsearch?

Deleting an index deletes its documents, shards, and metadata. It does not delete related Kibana components, such as data views, visualizations, or dashboards.

How do I delete all indices in Elasticsearch?

To delete all indices, use _all or * . To disallow the deletion of indices with _all or wildcard expressions, set the action. destructive_requires_name cluster setting to true .


1 Answers

Deleting a mapping type is not supported anymore since 2.0.

If you just need to delete the documents, then you may use the delete by query plugin, otherwise you should create a new index without the mapping you want to delete and reindex your data.

like image 151
Val Avatar answered Oct 07 '22 00:10

Val