Delete a document from an alias

I have some indexes on an ElasticSearch cluster containing the same kind documents (i.e. with the same mapping) and I'm using some aliases for different purposes.

Every month there's a Curator job which creates a new index (with the name pattern like "") and assigns/moves some aliases, two of them are "index-current" and "index-all". "index-current" is an alias for the latest (i.e. current month) index so it's assigned to a single index, while "index-all" is assigned to all the indexes. Basically I'm using the "index-current" one to index while the "index-all" for search.

I'd also to delete documents sometimes and I'd need to rely on the "index-all" alias to be sure I removed my document from everywhere, but it seems the delete command on an alias which includes multiple indexes is not working. Is there anything I am missing?

I thought to get the document, look into the _index field (which contains the name of the index the document is physically stored in) and send the delete command, but it's not a real solution (I mean, I could go with this but it's a workaround).

FYI I'm using the NEST driver and also I'd avoid to infer or having the index name as a property of the class I'm indexing.


You cannot make write operations using aliases which point to multiple indices. When you identify the documents you want to delete you will need to note the index, type and id of the document and include this logic in your client to direct the delete request to the correct index rather than trying to rely on the alias what I thought to be a workaround is not a workaround...

Thank you!