use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchScrollRequest in project elasticsearch by elastic.
the class RestSearchScrollAction method prepareRequest.
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
String scrollId = request.param("scroll_id");
SearchScrollRequest searchScrollRequest = new SearchScrollRequest();
searchScrollRequest.scrollId(scrollId);
String scroll = request.param("scroll");
if (scroll != null) {
searchScrollRequest.scroll(new Scroll(parseTimeValue(scroll, null, "scroll")));
}
request.withContentOrSourceParamParserOrNull(xContentParser -> {
if (xContentParser != null) {
try {
buildFromContent(xContentParser, searchScrollRequest);
} catch (IOException e) {
throw new IllegalArgumentException("Failed to parse request body", e);
}
}
});
return channel -> client.searchScroll(searchScrollRequest, new RestStatusToXContentListener<>(channel));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchScrollRequest in project elasticsearch by elastic.
the class RestSearchScrollActionTests method testParseSearchScrollRequest.
public void testParseSearchScrollRequest() throws Exception {
XContentParser content = createParser(XContentFactory.jsonBuilder().startObject().field("scroll_id", "SCROLL_ID").field("scroll", "1m").endObject());
SearchScrollRequest searchScrollRequest = new SearchScrollRequest();
RestSearchScrollAction.buildFromContent(content, searchScrollRequest);
assertThat(searchScrollRequest.scrollId(), equalTo("SCROLL_ID"));
assertThat(searchScrollRequest.scroll().keepAlive(), equalTo(TimeValue.parseTimeValue("1m", null, "scroll")));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchScrollRequest in project graylog2-server by Graylog2.
the class ScrollResultES7 method nextSearchResult.
private SearchResponse nextSearchResult() throws IOException {
final SearchScrollRequest scrollRequest = new SearchScrollRequest(this.scrollId);
scrollRequest.scroll(TimeValue.parseTimeValue(this.scroll, DEFAULT_SCROLL, "scroll time"));
return client.executeWithIOException((c, requestOptions) -> c.scroll(scrollRequest, requestOptions), "Unable to retrieve next chunk from search: ");
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchScrollRequest in project elasticsearch by elastic.
the class ClientScrollableHitSource method doStartNextScroll.
@Override
protected void doStartNextScroll(String scrollId, TimeValue extraKeepAlive, Consumer<? super Response> onResponse) {
searchWithRetry(listener -> {
SearchScrollRequest request = new SearchScrollRequest();
request.scrollId(scrollId).scroll(timeValueNanos(firstSearchRequest.scroll().keepAlive().nanos() + extraKeepAlive.nanos()));
client.searchScroll(request, listener);
}, r -> consume(r, onResponse));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchScrollRequest in project elasticsearch by elastic.
the class RestSearchScrollActionTests method testParseSearchScrollRequestWithUnknownParamThrowsException.
public void testParseSearchScrollRequestWithUnknownParamThrowsException() throws Exception {
SearchScrollRequest searchScrollRequest = new SearchScrollRequest();
XContentParser invalidContent = createParser(XContentFactory.jsonBuilder().startObject().field("scroll_id", "value_2").field("unknown", "keyword").endObject());
Exception e = expectThrows(IllegalArgumentException.class, () -> RestSearchScrollAction.buildFromContent(invalidContent, searchScrollRequest));
assertThat(e.getMessage(), startsWith("Unknown parameter [unknown]"));
}
Aggregations