use of org.elasticsearch.action.search.MultiSearchRequest in project elasticsearch by elastic.
the class RestMultiSearchAction method parseRequest.
/**
* Parses a {@link RestRequest} body and returns a {@link MultiSearchRequest}
*/
public static MultiSearchRequest parseRequest(RestRequest restRequest, boolean allowExplicitIndex) throws IOException {
MultiSearchRequest multiRequest = new MultiSearchRequest();
if (restRequest.hasParam("max_concurrent_searches")) {
multiRequest.maxConcurrentSearchRequests(restRequest.paramAsInt("max_concurrent_searches", 0));
}
parseMultiLineRequest(restRequest, multiRequest.indicesOptions(), allowExplicitIndex, (searchRequest, parser) -> {
try {
final QueryParseContext queryParseContext = new QueryParseContext(parser);
searchRequest.source(SearchSourceBuilder.fromXContent(queryParseContext));
multiRequest.add(searchRequest);
} catch (IOException e) {
throw new ElasticsearchParseException("Exception when parsing search request", e);
}
});
return multiRequest;
}
use of org.elasticsearch.action.search.MultiSearchRequest in project camel by apache.
the class ElasticsearchActionRequestConverter method toMultiSearchRequest.
@SuppressWarnings("unchecked")
@Converter
public static MultiSearchRequest toMultiSearchRequest(Object document, Exchange exchange) {
List<SearchRequest> items = (List<SearchRequest>) document;
MultiSearchRequest multiSearchRequest = new MultiSearchRequest();
Iterator<SearchRequest> it = items.iterator();
while (it.hasNext()) {
SearchRequest item = it.next();
multiSearchRequest.add(item);
}
return multiSearchRequest;
}
use of org.elasticsearch.action.search.MultiSearchRequest in project camel by apache.
the class ElasticsearchActionRequestConverter method toMultiSearchRequest.
@Converter
public static MultiSearchRequest toMultiSearchRequest(Object document, Exchange exchange) {
List<SearchRequest> items = (List<SearchRequest>) document;
MultiSearchRequest multiSearchRequest = new MultiSearchRequest();
Iterator<SearchRequest> it = items.iterator();
while (it.hasNext()) {
SearchRequest item = it.next();
multiSearchRequest.add(item);
}
return multiSearchRequest;
}
use of org.elasticsearch.action.search.MultiSearchRequest in project graylog2-server by Graylog2.
the class ElasticsearchClient method msearch.
public List<MultiSearchResponse.Item> msearch(List<SearchRequest> searchRequests, String errorMessage) {
final MultiSearchRequest multiSearchRequest = new MultiSearchRequest();
searchRequests.forEach(multiSearchRequest::add);
final MultiSearchResponse result = this.execute((c, requestOptions) -> c.msearch(multiSearchRequest, requestOptions), errorMessage);
return Streams.stream(result).collect(Collectors.toList());
}
use of org.elasticsearch.action.search.MultiSearchRequest in project graylog2-server by Graylog2.
the class ElasticsearchClient method search.
public SearchResponse search(SearchRequest searchRequest, String errorMessage) {
final MultiSearchRequest multiSearchRequest = new MultiSearchRequest().add(searchRequest);
final MultiSearchResponse result = this.execute((c, requestOptions) -> c.msearch(multiSearchRequest, requestOptions), errorMessage);
return firstResponseFrom(result, errorMessage);
}
Aggregations