Hi,
you can use the delete-by-query plugin for that. Here's an example:
We create an index with two types and add some documents:
POST /_bulk
{"index":{"_index":"mammals","_type":"people"}}
{"tag_line":"I am Mike"}
{"index":{"_index":"mammals","_type":"people"}}
{"tag_line":"I am Hanna"}
{"index":{"_index":"mammals","_type":"people"}}
{"tag_line":"I am Bert"}
{"index":{"_index":"mammals","_type":"animals"}}
{"tag_line":"I am a dog"}
{"index":{"_index":"mammals","_type":"animals"}}
{"tag_line":"I am a cat"}
When we query for all documents, we get 5 results:
GET /mammals/_search?size=0
{
"query": {
"match_all": {}
}
}
Now we can delete all documents of the type "animals":
DELETE /mammals/animals/_query
{
"query": {
"match_all": {}
}
}
This will only work when the delete-by-query plugin is installed.
When we search once again for all documents, we only get 3 results as the animals are gone.
Daniel