return SearchIntoAction.INSTANCE;
}
public void handleRequest(final RestRequest request,
final RestChannel channel) {
SearchIntoRequest searchIntoRequest = new SearchIntoRequest(
RestActions.splitIndices(request.param("index")));
if (request.hasParam("ignore_indices")) {
searchIntoRequest.ignoreIndices(IgnoreIndices.fromString(
request.param(
"ignore_indices")));
}
searchIntoRequest.listenerThreaded(false);
try {
BroadcastOperationThreading operationThreading =
BroadcastOperationThreading.fromString(
request.param("operation_threading"),
BroadcastOperationThreading.SINGLE_THREAD);
if (operationThreading == BroadcastOperationThreading.NO_THREADS) {
// since we don't spawn, don't allow no_threads,
// but change it to a single thread
operationThreading = BroadcastOperationThreading.SINGLE_THREAD;
}
searchIntoRequest.operationThreading(operationThreading);
if (request.hasContent()) {
searchIntoRequest.source(request.content(),
request.contentUnsafe());
} else {
String source = request.param("source");
if (source != null) {
searchIntoRequest.source(source);
} else {
BytesReference querySource = RestActions.parseQuerySource(
request);
if (querySource != null) {
searchIntoRequest.source(querySource, false);
}
}
}
searchIntoRequest.routing(request.param("routing"));
searchIntoRequest.types(splitTypes(request.param("type")));
searchIntoRequest.preference(request.param("preference",
"_primary"));
} catch (Exception e) {
try {
XContentBuilder builder = RestXContentBuilder
.restContentBuilder(