use of org.elasticsearch.action.ActionRequestValidationException in project elasticsearch by elastic.
the class AbstractBaseReindexRestHandler method doPrepareRequest.
protected RestChannelConsumer doPrepareRequest(RestRequest request, NodeClient client, boolean includeCreated, boolean includeUpdated) throws IOException {
// Build the internal request
Request internal = setCommonOptions(request, buildRequest(request));
// Executes the request and waits for completion
if (request.paramAsBoolean("wait_for_completion", true)) {
Map<String, String> params = new HashMap<>();
params.put(BulkByScrollTask.Status.INCLUDE_CREATED, Boolean.toString(includeCreated));
params.put(BulkByScrollTask.Status.INCLUDE_UPDATED, Boolean.toString(includeUpdated));
return channel -> client.executeLocally(action, internal, new BulkIndexByScrollResponseContentListener(channel, params));
} else {
internal.setShouldStoreResult(true);
}
/*
* Let's try and validate before forking so the user gets some error. The
* task can't totally validate until it starts but this is better than
* nothing.
*/
ActionRequestValidationException validationException = internal.validate();
if (validationException != null) {
throw validationException;
}
return sendTask(client.getLocalNodeId(), client.executeLocally(action, internal, LoggingTaskListener.instance()));
}
use of org.elasticsearch.action.ActionRequestValidationException in project elasticsearch by elastic.
the class ReindexRequestTests method testReindexFromRemoteDoesNotSupportSearchQuery.
public void testReindexFromRemoteDoesNotSupportSearchQuery() {
ReindexRequest reindex = newRequest();
reindex.setRemoteInfo(new RemoteInfo(randomAsciiOfLength(5), randomAsciiOfLength(5), between(1, Integer.MAX_VALUE), new BytesArray("real_query"), null, null, emptyMap(), RemoteInfo.DEFAULT_SOCKET_TIMEOUT, RemoteInfo.DEFAULT_CONNECT_TIMEOUT));
// Unsupported place to put query
reindex.getSearchRequest().source().query(matchAllQuery());
ActionRequestValidationException e = reindex.validate();
assertEquals("Validation Failed: 1: reindex from remote sources should use RemoteInfo's query instead of source's query;", e.getMessage());
}
use of org.elasticsearch.action.ActionRequestValidationException in project elasticsearch by elastic.
the class ReindexRequestTests method testNoSliceWithWorkers.
public void testNoSliceWithWorkers() {
ReindexRequest reindex = newRequest();
reindex.getSearchRequest().source().slice(new SliceBuilder(0, 4));
reindex.setSlices(between(2, Integer.MAX_VALUE));
ActionRequestValidationException e = reindex.validate();
assertEquals("Validation Failed: 1: can't specify both slice and workers;", e.getMessage());
}
Aggregations