Purge last N documents from ElasticSerach

Is there a way to purge last N documents from Elasticsearch?.
Use-case is, Purging documents based on the count.
For example, assume that the document count threshold was set to 1million and current document count is 1.1 million. I need to purge the last 0.1 million documents.

Welcome.

Not really. Elasticsearch does not really know what are the first or the last documents unless you have a field in the documentation which can tell that (a counter, a date...).

Did you mean to purge the last N documents or the first N documents? What exactly is the use case for this?

We have a timestamp field in the report.
Use-case: Purge criteria is based on number of documents.
Assume that doucment count threshold is 1 million. If total count of documents is 1.2 million then need to delete last 0.2 million documents.

I don't see a way to do that.

And I don't understand the need you described. Why do you need such a threshold?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.