controller.registerHandler(POST, "/{index}/{type}/_validate/query", this);
}
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
ValidateQueryRequest validateQueryRequest = new ValidateQueryRequest(Strings.splitStringByCommaToArray(request.param("index")));
validateQueryRequest.listenerThreaded(false);
validateQueryRequest.indicesOptions(IndicesOptions.fromRequest(request, validateQueryRequest.indicesOptions()));
if (request.hasContent()) {
validateQueryRequest.source(request.content(), request.contentUnsafe());
} else {
String source = request.param("source");
if (source != null) {
validateQueryRequest.source(source);
} else {
QuerySourceBuilder querySourceBuilder = RestActions.parseQuerySource(request);
if (querySourceBuilder != null) {
validateQueryRequest.source(querySourceBuilder);
}
}
}
validateQueryRequest.types(Strings.splitStringByCommaToArray(request.param("type")));
if (request.paramAsBoolean("explain", false)) {
validateQueryRequest.explain(true);
} else {
validateQueryRequest.explain(false);
}
client.admin().indices().validateQuery(validateQueryRequest, new RestBuilderListener<ValidateQueryResponse>(channel) {
@Override
public RestResponse buildResponse(ValidateQueryResponse response, XContentBuilder builder) throws Exception {