Hi,
this works fine indeed. Here's a complete example based on Elasticsearch 2.2:
Install the delete-by-query
plugin:
bin/plugin install delete-by-query
Create a few documents in multiple indices:
POST /_bulk
{"index":{"_index":"logs-2014","_type":"click"}}
{"ip_address":"1.1.1.1","event":"click"}
{"index":{"_index":"logs-2014","_type":"click"}}
{"ip_address":"1.1.1.1","event":"buy"}
{"index":{"_index":"logs-2015","_type":"click"}}
{"ip_address":"1.1.1.1","event":"click"}
{"index":{"_index":"logs-2015","_type":"click"}}
{"ip_address":"1.1.1.1","event":"buy"}
{"index":{"_index":"logs-2016","_type":"click"}}
{"ip_address":"1.1.1.1","event":"click"}
{"index":{"_index":"logs-2016","_type":"click"}}
{"ip_address":"1.1.1.1","event":"buy"}
{"index":{"_index":"logs-2016","_type":"click"}}
{"ip_address":"1.1.1.1","event":"click"}
Add a logs
alias for all these indices:
POST /_aliases
{
"actions" : [
{ "add" : { "index" : "logs-2014", "alias" : "logs" } },
{ "add" : { "index" : "logs-2015", "alias" : "logs" } },
{ "add" : { "index" : "logs-2016", "alias" : "logs" } }
]
}
Check that we actually have documents across multiple indices:
GET /logs/_search
{
"query": {
"match_all": { }
}
}
Now delete all "click" events across all indices (based on the alias logs
):
DELETE /logs/_query
{
"query": {
"match": {
"event": {
"query": "click"
}
}
}
}
This returns:
{
"took": 0,
"timed_out": false,
"_indices": {
"_all": {
"found": 4,
"deleted": 4,
"missing": 0,
"failed": 0
},
"logs-2015": {
"found": 1,
"deleted": 1,
"missing": 0,
"failed": 0
},
"logs-2016": {
"found": 2,
"deleted": 2,
"missing": 0,
"failed": 0
},
"logs-2014": {
"found": 1,
"deleted": 1,
"missing": 0,
"failed": 0
}
},
"failures": []
}
Daniel