Refine search
private void processScroll(InternalScrollSearchRequest request, SearchContext context) throws IOException { // process scroll context.from(context.from() + context.size()); context.scrollContext().scroll = request.scroll(); // update the context keep alive based on the new scroll value if (request.scroll() != null && request.scroll().keepAlive() != null) { contextScrollKeepAlive(context, request.scroll().keepAlive().millis()); } }
/** * If set, will enable scrolling of the search request for the specified timeout. */ public SearchRequest scroll(String keepAlive) { return scroll(new Scroll(TimeValue.parseTimeValue(keepAlive, null, getClass().getSimpleName() + ".Scroll.keepAlive"))); }
@Override protected void doStartNextScroll(String scrollId, TimeValue extraKeepAlive, Consumer<? super Response> onResponse) { searchWithRetry(listener -> { SearchScrollRequest request = new SearchScrollRequest(); // Add the wait time into the scroll timeout so it won't timeout while we wait for throttling request.scrollId(scrollId).scroll(timeValueNanos(firstSearchRequest.scroll().keepAlive().nanos() + extraKeepAlive.nanos())); client.searchScroll(request, listener); }, r -> consume(r, onResponse)); }
@Override public Flux<SearchHit> scroll(HttpHeaders headers, SearchRequest searchRequest) { TimeValue scrollTimeout = searchRequest.scroll() != null ? searchRequest.scroll().keepAlive() : TimeValue.timeValueMinutes(1);
ArrayList< SearchHit > searchHitsA = new ArrayList<>(); final Scroll scroll = new Scroll(TimeValue.timeValueMinutes(1L)); SearchRequest searchRequest = new SearchRequest(this.RIVER_INDEX); searchRequest.scroll(scroll);
TimeValue keepAlive = searchRequest.scroll().keepAlive(); if (remoteVersion.before(Version.V_5_0_0)) { keepAlive = timeValueMillis((long) Math.ceil(keepAlive.millisFrac())); request.addParameter("scroll", keepAlive.getStringRep());
model.setScrollSize(((Number) SettingsUtils.get(scrollSettings, "size", 1000)).intValue()); model.setScrollKeepAlive(new Scroll(TimeValue .timeValueSeconds(((Number) SettingsUtils.get( scrollSettings, "keep_alive", 60L)).longValue())));
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field("scroll_id", scrollId); if (scroll != null) { builder.field("scroll", scroll.keepAlive().getStringRep()); } builder.endObject(); return builder; }
private static void addSearchRequestParams(Params params, SearchRequest searchRequest) { params.putParam("typed_keys", "true"); params.withRouting(searchRequest.routing()); params.withPreference(searchRequest.preference()); params.withIndicesOptions(searchRequest.indicesOptions()); params.putParam("search_type", searchRequest.searchType().name().toLowerCase(Locale.ROOT)); if (searchRequest.requestCache() != null) { params.putParam("request_cache", Boolean.toString(searchRequest.requestCache())); } if (searchRequest.allowPartialSearchResults() != null) { params.putParam("allow_partial_search_results", Boolean.toString(searchRequest.allowPartialSearchResults())); } params.putParam("batched_reduce_size", Integer.toString(searchRequest.getBatchedReduceSize())); if (searchRequest.scroll() != null) { params.putParam("scroll", searchRequest.scroll().keepAlive()); } }
/** * If set, will enable scrolling of the search request for the specified timeout. */ public SearchScrollRequest scroll(TimeValue keepAlive) { return scroll(new Scroll(keepAlive)); }
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); types = in.readStringArray(); source = in.readBytesReference(); routing = in.readOptionalString(); size = in.readVInt(); if (in.readBoolean()) { scroll = readScroll(in); } if (in.readBoolean()) { timeout = TimeValue.readTimeValue(in); } }
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); scrollId = in.readString(); if (in.readBoolean()) { scroll = readScroll(in); } }
@Override protected void doStartNextScroll(String scrollId, TimeValue extraKeepAlive, Consumer<? super Response> onResponse) { TimeValue keepAlive = timeValueNanos(searchRequest.scroll().keepAlive().nanos() + extraKeepAlive.nanos()); execute(RemoteRequestBuilders.scroll(scrollId, keepAlive, remoteVersion), RESPONSE_PARSER, onResponse); }
final Scroll scroll = new Scroll(TimeValue.timeValueMinutes(1L)); SearchRequest searchRequest = new SearchRequest(); searchRequest.indices(indexName).types(typeName);
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field("scroll_id", scrollId); if (scroll != null) { builder.field("scroll", scroll.keepAlive().getStringRep()); } builder.endObject(); return builder; }
/** * Get scroll timeout */ public TimeValue getScrollTime() { return searchRequest.scroll().keepAlive(); }
/** * If set, will enable scrolling of the search request for the specified timeout. */ public SearchRequest scroll(TimeValue keepAlive) { return scroll(new Scroll(keepAlive)); }