use of org.elasticsearch.action.bulk.byscroll.DeleteByQueryRequest in project elasticsearch by elastic.
the class RestDeleteByQueryAction method buildRequest.
@Override
protected DeleteByQueryRequest buildRequest(RestRequest request) throws IOException {
if (false == request.hasContent()) {
throw new ElasticsearchException("_delete_by_query requires a request body");
}
/*
* Passing the search request through DeleteByQueryRequest first allows
* it to set its own defaults which differ from SearchRequest's
* defaults. Then the parseInternalRequest can override them.
*/
DeleteByQueryRequest internal = new DeleteByQueryRequest(new SearchRequest());
Map<String, Consumer<Object>> consumers = new HashMap<>();
consumers.put("conflicts", o -> internal.setConflicts((String) o));
parseInternalRequest(internal, request, consumers);
return internal;
}
use of org.elasticsearch.action.bulk.byscroll.DeleteByQueryRequest in project elasticsearch by elastic.
the class RoundTripTests method testDeleteByQueryRequest.
public void testDeleteByQueryRequest() throws IOException {
DeleteByQueryRequest delete = new DeleteByQueryRequest(new SearchRequest());
randomRequest(delete);
DeleteByQueryRequest tripped = new DeleteByQueryRequest();
roundTrip(delete, tripped);
assertRequestEquals(delete, tripped);
// Try slices with a version that doesn't support slices. That should fail.
delete.setSlices(between(2, 1000));
Exception e = expectThrows(IllegalArgumentException.class, () -> roundTrip(Version.V_5_0_0_rc1, delete, null));
assertEquals("Attempting to send sliced reindex-style request to a node that doesn't support it. " + "Version is [5.0.0-rc1] but must be [5.1.1]", e.getMessage());
// Try without slices with a version that doesn't support slices. That should work.
tripped = new DeleteByQueryRequest();
delete.setSlices(1);
roundTrip(Version.V_5_0_0_rc1, delete, tripped);
assertRequestEquals(delete, tripped);
}
Aggregations