New

The executive guide to generative AI

Read more
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.

Terminate After

edit

The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. If set, you will be able to check if the operation terminated early by asking for isTerminatedEarly() in the SearchResponse onject:

SearchResponse sr = client.prepareSearch(INDEX)
    .setTerminateAfter(1000)    
    .get();

if (sr.isTerminatedEarly()) {
    // We finished early
}

Finish after 1000 docs

Was this helpful?
Feedback