protected Observable<Void> clearScroll() { return defer(() -> { if (scrollId == null) { return aVoid(); } ClearScrollRequestBuilder request = elasticsearch.get().prepareClearScroll() .addScrollId(scrollId); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Request = " + Jsonify.toString(request)); } return elasticsearch.execute(vertxContext, request, elasticsearch.getDefaultGetTimeout()) .onErrorResumeNext(throwable -> { LOGGER.warn("Handling Clear Scroll Error", throwable); return just(null); }) .map(new ToVoid<>()); }); }
protected <E extends EsDocument> ScrollableResponse<List<E>> scrollNext( String scrollId, ThrowingFunction<String, E> createFunc) throws Exception { SearchScrollRequestBuilder builder = esClient.prepareSearchScroll(scrollId) .setScroll(TimeValue.timeValueMillis(SCROLLDEFAULTTIMEOUT)); SearchResponse response = builder.execute().actionGet(); ArrayList<E> list = new ArrayList<>(); ScrollableResponse<List<E>> ret = new ScrollableResponse<>(); ret.setValue(list); ret.setContinousToken(response.getScrollId()); if (response.getHits().totalHits() == 0) { //Clear the scroll as early as possible to save resource ClearScrollRequestBuilder clearRequestBuilder = esClient.prepareClearScroll().addScrollId(scrollId); clearRequestBuilder.execute(); ret.setScrollToEnd(true); } else { for (int i = 0; i < response.getHits().getHits().length; i++) { String str = response.getHits().getAt(i).getSourceAsString(); E element = createFunc.apply(str); element.setId(response.getHits().getAt(i).getId()); list.add(element); } } return ret; }
protected Observable<Void> clearScroll(Elasticsearch elasticSearch, String scrollId) { ClearScrollRequestBuilder request = elasticSearch.get() .prepareClearScroll() .addScrollId(scrollId); return elasticSearch.execute(vertxContext, request, elasticSearch.getDefaultSearchTimeout()) .onErrorResumeNext(throwable -> { LOGGER.warn("Handling Clear Scroll Error", throwable); return just(null); }) .map(clearScrollResponseOptional -> null); }
protected Observable<Void> clearScroll(Elasticsearch elasticSearch, String scrollId) { ClearScrollRequestBuilder request = elasticSearch.get() .prepareClearScroll() .addScrollId(scrollId); return elasticSearch.execute(vertxContext, request, elasticSearch.getDefaultSearchTimeout()) .onErrorResumeNext(throwable -> { LOGGER.warn("Handling Clear Scroll Error", throwable); return Defer.just(null); }) .map(clearScrollResponseOptional -> null); }
public ClearScrollRequestBuilder prepareClearScroll(String scrollId) { return client.prepareClearScroll().addScrollId(scrollId); }
@Override public ClearScrollRequestBuilder prepareClearScroll() { return new ClearScrollRequestBuilder(this, ClearScrollAction.INSTANCE); }
@Override public ClearScrollRequestBuilder prepareClearScroll() { // TODO Auto-generated method stub return null; }
@Override public void closeNow() { ClearScrollRequestBuilder scrollRequestBuilder = new ClearScrollRequestBuilder(_client, ClearScrollAction.INSTANCE).addScrollId(_searchResponse.getScrollId()); scrollRequestBuilder.execute(); }
/** * Clears the search contexts associated with specified scroll ids. */ ClearScrollRequestBuilder prepareClearScroll();