org.elasticsearch.action.search.ClearScrollRequestBuilder Java Examples

The following examples show how to use org.elasticsearch.action.search.ClearScrollRequestBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScanAndScrollStreamProducer.java    From sfs with Apache License 2.0 6 votes vote down vote up
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<>());
    });
}
 
Example #2
Source File: EsStore.java    From soundwave with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #3
Source File: ListContainers.java    From sfs with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #4
Source File: ListObjects.java    From sfs with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #5
Source File: ElasticClient.java    From Stargraph with MIT License 4 votes vote down vote up
public ClearScrollRequestBuilder prepareClearScroll(String scrollId) {
    return client.prepareClearScroll().addScrollId(scrollId);
}
 
Example #6
Source File: ClientWithStats.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public ClearScrollRequestBuilder prepareClearScroll() {
	return wrapped.prepareClearScroll();
}
 
Example #7
Source File: FessEsClient.java    From fess with Apache License 2.0 4 votes vote down vote up
@Override
public ClearScrollRequestBuilder prepareClearScroll() {
    return client.prepareClearScroll();
}