org.elasticsearch.client.Client.searchScroll()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(225)

本文整理了Java中org.elasticsearch.client.Client.searchScroll()方法的一些代码示例,展示了Client.searchScroll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Client.searchScroll()方法的具体详情如下:
包路径:org.elasticsearch.client.Client
类名称:Client
方法名:searchScroll

Client.searchScroll介绍

[英]A search scroll request to continue searching a previous scrollable search request.
[中]搜索滚动请求以继续搜索以前的可滚动搜索请求。

代码示例

代码示例来源:origin: NLPchina/elasticsearch-sql

client.searchScroll((SearchScrollRequest) request, new RestStatusToXContentListener<>(channel));
} else {
  throw new Exception(String.format("Unsupported ActionRequest provided: %s", request.getClass().getName()));

代码示例来源:origin: javanna/elasticshell

@Override
protected ActionFuture<SearchResponse> doExecute(SearchScrollRequest request) {
  return client.searchScroll(request);
}

代码示例来源:origin: org.nuxeo.elasticsearch/nuxeo-elasticsearch-core

@Override
public SearchResponse searchScroll(SearchScrollRequest request) {
  return client.searchScroll(request).actionGet();
}

代码示例来源:origin: com.strapdata.elasticsearch.module/reindex

/**
 * Start the next scroll request.
 *
 * @param lastBatchSize the number of requests sent in the last batch. This is used to calculate the throttling values which are applied
 *        when the scroll returns
 */
void startNextScroll(int lastBatchSize) {
  if (task.isCancelled()) {
    finishHim(null);
    return;
  }
  final long earliestNextBatchStartTime = lastBatchStartTime.get() + (long) perfectlyThrottledBatchTime(lastBatchSize);
  long waitTime = max(0, earliestNextBatchStartTime - System.nanoTime());
  SearchScrollRequest request = new SearchScrollRequest(mainRequest);
  // Add the wait time into the scroll timeout so it won't timeout while we wait for throttling
  request.scrollId(scroll.get()).scroll(timeValueNanos(firstSearchRequest.scroll().keepAlive().nanos() + waitTime));
  client.searchScroll(request, new ActionListener<SearchResponse>() {
    @Override
    public void onResponse(SearchResponse response) {
      onScrollResponse(timeValueNanos(max(0, earliestNextBatchStartTime - System.nanoTime())), response);
    }
    @Override
    public void onFailure(Throwable e) {
      finishHim(e);
    }
  });
}

代码示例来源:origin: org.elasticsearch.module/reindex

/**
 * Start the next scroll request.
 *
 * @param lastBatchSize the number of requests sent in the last batch. This is used to calculate the throttling values which are applied
 *        when the scroll returns
 */
void startNextScroll(int lastBatchSize) {
  if (task.isCancelled()) {
    finishHim(null);
    return;
  }
  final long earliestNextBatchStartTime = lastBatchStartTime.get() + (long) perfectlyThrottledBatchTime(lastBatchSize);
  long waitTime = max(0, earliestNextBatchStartTime - System.nanoTime());
  SearchScrollRequest request = new SearchScrollRequest(mainRequest);
  // Add the wait time into the scroll timeout so it won't timeout while we wait for throttling
  request.scrollId(scroll.get()).scroll(timeValueNanos(firstSearchRequest.scroll().keepAlive().nanos() + waitTime));
  client.searchScroll(request, new ActionListener<SearchResponse>() {
    @Override
    public void onResponse(SearchResponse response) {
      onScrollResponse(timeValueNanos(max(0, earliestNextBatchStartTime - System.nanoTime())), response);
    }
    @Override
    public void onFailure(Throwable e) {
      finishHim(e);
    }
  });
}

代码示例来源:origin: org.nlpcn/elasticsearch-sql

/**
 * Execute the ActionRequest and returns the REST response using the channel.
 */
@Override
public void execute(Client client, Map<String, String> params, QueryAction queryAction, RestChannel channel) throws Exception {
  SqlElasticRequestBuilder requestBuilder = queryAction.explain();
  ActionRequest request = requestBuilder.request();
  if (requestBuilder instanceof JoinRequestBuilder) {
    ElasticJoinExecutor executor = ElasticJoinExecutor.createJoinExecutor(client, requestBuilder);
    executor.run();
    executor.sendResponse(channel);
  } else if (requestBuilder instanceof MultiQueryRequestBuilder) {
    ElasticHitsExecutor executor = MultiRequestExecutorFactory.createExecutor(client, (MultiQueryRequestBuilder) requestBuilder);
    executor.run();
    sendDefaultResponse(executor.getHits(), channel);
  } else if (request instanceof SearchRequest) {
    client.search((SearchRequest) request, new RestStatusToXContentListener<>(channel));
  } else if (request instanceof DeleteByQueryRequest) {
    requestBuilder.getBuilder().execute(new BulkIndexByScrollResponseContentListener(channel, Maps.newHashMap()));
  } else if (request instanceof GetIndexRequest) {
    requestBuilder.getBuilder().execute(new GetIndexRequestRestListener(channel, (GetIndexRequest) request));
  } else if (request instanceof SearchScrollRequest) {
    client.searchScroll((SearchScrollRequest) request, new RestStatusToXContentListener<>(channel));
  } else {
    throw new Exception(String.format("Unsupported ActionRequest provided: %s", request.getClass().getName()));
  }
}

代码示例来源:origin: harbby/presto-connectors

@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
  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")));
  }
  if (RestActions.hasBodyContent(request)) {
    XContentType type = XContentFactory.xContentType(RestActions.getRestContent(request));
    if (type == null) {
      if (scrollId == null) {
        scrollId = RestActions.getRestContent(request).toUtf8();
        searchScrollRequest.scrollId(scrollId);
      }
    } else {
      // NOTE: if rest request with xcontent body has request parameters, these parameters override xcontent values
      buildFromContent(RestActions.getRestContent(request), searchScrollRequest);
    }
  }
  client.searchScroll(searchScrollRequest, new RestStatusToXContentListener<SearchResponse>(channel));
}

相关文章