Delete by Query in ES 5.0 Java Client

Hello,
Just starting off with ES. Ran into problem when trying to delete the indexed documents. Seems like the Delete by Query is no longer available in ES 5.0 Java client.
How do I achieve selective delete of documents from the Index using Java client. i.e. (A query determines which all documents to be deleted).
I am running ES in embedded(local) mode for the time being. Later it will run in production mode(Client/Server).

Can anyone please help me out.

Is it the same question as the following?

Hi. It looks the same.

Here is my code, but I haven't tried it yet. But there is no compilation error.

        QueryBuilder aQuery = QueryBuilders.termQuery("_parent", idParent);    

        DeleteByQueryRequestBuilder req = new DeleteByQueryRequestBuilder(this.getElasticClient(), DeleteByQueryAction.INSTANCE);
        **req.source()**                         // here is the trick
          .setIndices(index)
          .setTypes(type)
          .setRouting(idParent)
          .setQuery(aQuery);
        
        BulkIndexByScrollResponse resp = req.get();

        return resp.getDeleted();

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