The NumDocs field expression returns the total number of documents in the index.
This count includes documents that have been updated/deleted but not yet reclaimed from permanent storage.
NUMDOCS() AS ALIAS
- ALIAS - Field name for the resulting value.
NUMDOCS() as num.docs
QueryRequest request = new QueryRequest("*:*)"); request.addField(new NumDocs().as("num.docs")); // ... (Perform Search)