Get count of top-level deleted documents in Elasticsearch

I am looking to get an accurate count of deleted Elasticsearch documents excluding the nested documents at Lucene level. I am aware of the following APIs to get document and deleted document counts but none of them return the information I need.

  • GET myindex/_count API - Returns the top-level Elasticsearch documents.
  • GET _cat/indices/myindex API - Returns docs.count & deleted.docs that are taken directly from Lucene and include nested documents.
  • GET _cat/count/myindex API - Returns the top-level documents same as the 1st option.

For example: Suppose an index with 10 documents that are internally stored as 100 Lucene documents and I delete 5 documents, I want to get 5 instead of the count of deleted Lucene docs.

Is there a way to get the top-level deleted documents?

What are you looking to use this for? Deleted counts change as segments are merged so can vary over time. Is it an instant figure or an accumulate you are looking for?

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