New

The executive guide to generative AI

Read more

Delete By Query API

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

Delete By Query API

edit

The delete by query API allows one to delete documents from one or more indices and one or more types based on a query. Here is an example:

import static org.elasticsearch.index.query.FilterBuilders.*;
import static org.elasticsearch.index.query.QueryBuilders.*;

DeleteByQueryResponse response = client.prepareDeleteByQuery("test")
        .setQuery(termQuery("_type", "type1"))
        .execute()
        .actionGet();

For more information on the delete by query operation, check out the delete_by_query API docs.

Was this helpful?
Feedback