});
}
private SearchRequest parseSearchRequest(RestRequest request) {
String[] indices = RestActions.splitIndices(request.param("index"));
SearchRequest searchRequest = new SearchRequest(indices);
// get the content, and put it in the body
if (request.hasContent()) {
searchRequest.source(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength(), request.contentUnsafe());
} else {
String source = request.param("source");
if (source != null) {
searchRequest.source(source);
}
}
// add extra source based on the request parameters
searchRequest.extraSource(parseSearchSource(request));
searchRequest.searchType(request.param("search_type"));
String scroll = request.param("scroll");
if (scroll != null) {
searchRequest.scroll(new Scroll(parseTimeValue(scroll, null)));
}
searchRequest.timeout(request.paramAsTime("timeout", null));
searchRequest.types(RestActions.splitTypes(request.param("type")));
searchRequest.queryHint(request.param("query_hint"));
searchRequest.routing(request.param("routing"));
searchRequest.preference(request.param("preference"));
return searchRequest;
}