super(settings, controller, client);
}
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
final ExistsRequest existsRequest = new ExistsRequest(Strings.splitStringByCommaToArray(request.param("index")));
existsRequest.indicesOptions(IndicesOptions.fromRequest(request, existsRequest.indicesOptions()));
existsRequest.listenerThreaded(false);
if (request.hasContent()) {
existsRequest.source(request.content(), request.contentUnsafe());
} else {
String source = request.param("source");
if (source != null) {
existsRequest.source(source);
} else {
QuerySourceBuilder querySourceBuilder = RestActions.parseQuerySource(request);
if (querySourceBuilder != null) {
existsRequest.source(querySourceBuilder);
}
}
}
existsRequest.routing(request.param("routing"));
existsRequest.minScore(request.paramAsFloat("min_score", DEFAULT_MIN_SCORE));
existsRequest.types(Strings.splitStringByCommaToArray(request.param("type")));
existsRequest.preference(request.param("preference"));
client.exists(existsRequest, new RestBuilderListener<ExistsResponse>(channel) {
@Override
public RestResponse buildResponse(ExistsResponse response, XContentBuilder builder) throws Exception {
RestStatus status = response.exists() ? OK : NOT_FOUND;