@Override public void clearScroll(String scrollId) { ClearScrollRequest request = new ClearScrollRequest(); request.addScrollId(scrollId); try { // TODO: Something useful with the response. ClearScrollResponse response = client.clearScroll(request); } catch (IOException e) { throw new ElasticsearchException("Error for search request with scroll: " + request.toString(), e); } }
private Publisher<?> cleanupScroll(HttpHeaders headers, ScrollState state) { if (state.getScrollIds().isEmpty()) { return Mono.empty(); } ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); clearScrollRequest.scrollIds(state.getScrollIds()); // just send the request, resources get cleaned up anyways after scrollTimeout has been reached. return sendRequest(clearScrollRequest, RequestCreator.clearScroll(), ClearScrollResponse.class, headers); }
public ClearScrollRequestBuilder(ElasticsearchClient client, ClearScrollAction action) { super(client, action, new ClearScrollRequest()); }
@Override public void clearScroll(String scrollId, Runnable onCompletion) { ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); clearScrollRequest.addScrollId(scrollId); /* * Unwrap the client so we don't set our task as the parent. If we *did* set our ID then the clear scroll would be cancelled as * if this task is cancelled. But we want to clear the scroll regardless of whether or not the main request was cancelled. */ client.unwrap().clearScroll(clearScrollRequest, new ActionListener<ClearScrollResponse>() { @Override public void onResponse(ClearScrollResponse response) { logger.debug("Freed [{}] contexts", response.getNumFreed()); onCompletion.run(); } @Override public void onFailure(Exception e) { logger.warn(() -> new ParameterizedMessage("Failed to clear scroll [{}]", scrollId), e); onCompletion.run(); } }); }
@Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { String scrollIds = request.param("scroll_id"); ClearScrollRequest clearRequest = new ClearScrollRequest(); clearRequest.setScrollIds(Arrays.asList(Strings.splitStringByCommaToArray(scrollIds))); request.withContentOrSourceParamParserOrNull((xContentParser -> { if (xContentParser != null) { // NOTE: if rest request with xcontent body has request parameters, values parsed from request body have the precedence try { clearRequest.fromXContent(xContentParser); } catch (IOException e) { throw new IllegalArgumentException("Failed to parse request body", e); } } })); return channel -> client.clearScroll(clearRequest, new RestStatusToXContentListener<>(channel)); }
public ClearScrollRequestBuilder(ElasticsearchClient client, ClearScrollAction action) { super(client, action, new ClearScrollRequest()); }
public ClearScrollRequestBuilder(ElasticsearchClient client, ClearScrollAction action) { super(client, action, new ClearScrollRequest()); }
public ClearScrollRequestBuilder(ElasticsearchClient client, ClearScrollAction action) { super(client, action, new ClearScrollRequest()); }
public ClearScrollRequestBuilder(ElasticsearchClient client, ClearScrollAction action) { super(client, action, new ClearScrollRequest()); }
protected void clearScroll(String scrollId) { if (log.isDebugEnabled()) { log.debug(String.format( "Clear scroll : curl -XDELETE 'http://localhost:9200/_search/scroll' -d '{\"scroll_id\" : [\"%s\"]}'", scrollId)); } ClearScrollRequest request = new ClearScrollRequest(); request.addScrollId(scrollId); esa.getClient().clearScroll(request); }
@Override public void closeNow() { final String scrollId = _searchResponse.getScrollId(); final ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); clearScrollRequest.addScrollId(scrollId); try { _client.execute(clearScrollRequest); } catch (IOException e) { logger.warn("Could not clear scroll.", e); } }
@Override public void close() { ClearScrollRequest request = new ClearScrollRequest(); request.addScrollId(scrollId); esClient.clearScroll(request); end = true; // Call super close to clear cursor super.close(); }
private void closeSearchContext(String scrollId) { ClearScrollRequest request = new ClearScrollRequest(); request.addScrollId(scrollId); // Perform this clean-up asynchronously because the client doesn't require the result. clientFactory.getHighLevelClient().clearScrollAsync(request, new ActionListener<ClearScrollResponse>() { @Override public void onResponse(ClearScrollResponse response) { if (!response.isSucceeded()) { LOGGER.warning("Could not close search context (response code %s).", response.status()); } else { LOGGER.debug("Successfully closed search context."); } } @Override public void onFailure(Exception ex) { LOGGER.warning(ex, "Could not close search context."); } }); }
@Override public void clearScroll(String scrollId, Runnable onCompletion) { ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); clearScrollRequest.addScrollId(scrollId); /* * Unwrap the client so we don't set our task as the parent. If we *did* set our ID then the clear scroll would be cancelled as * if this task is cancelled. But we want to clear the scroll regardless of whether or not the main request was cancelled. */ client.unwrap().clearScroll(clearScrollRequest, new ActionListener<ClearScrollResponse>() { @Override public void onResponse(ClearScrollResponse response) { logger.debug("Freed [{}] contexts", response.getNumFreed()); onCompletion.run(); } @Override public void onFailure(Exception e) { logger.warn(() -> new ParameterizedMessage("Failed to clear scroll [{}]", scrollId), e); onCompletion.run(); } }); }
@Override public void clearScroll(String scrollId, Runnable onCompletion) { ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); clearScrollRequest.addScrollId(scrollId); /* * Unwrap the client so we don't set our task as the parent. If we *did* set our ID then the clear scroll would be cancelled as * if this task is cancelled. But we want to clear the scroll regardless of whether or not the main request was cancelled. */ client.unwrap().clearScroll(clearScrollRequest, new ActionListener<ClearScrollResponse>() { @Override public void onResponse(ClearScrollResponse response) { logger.debug("Freed [{}] contexts", response.getNumFreed()); onCompletion.run(); } @Override public void onFailure(Exception e) { logger.warn((Supplier<?>) () -> new ParameterizedMessage("Failed to clear scroll [{}]", scrollId), e); onCompletion.run(); } }); }
@Override public void clearScroll(String scrollId, Runnable onCompletion) { ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); clearScrollRequest.addScrollId(scrollId); /* * Unwrap the client so we don't set our task as the parent. If we *did* set our ID then the clear scroll would be cancelled as * if this task is cancelled. But we want to clear the scroll regardless of whether or not the main request was cancelled. */ client.unwrap().clearScroll(clearScrollRequest, new ActionListener<ClearScrollResponse>() { @Override public void onResponse(ClearScrollResponse response) { logger.debug("Freed [{}] contexts", response.getNumFreed()); onCompletion.run(); } @Override public void onFailure(Exception e) { logger.warn(() -> new ParameterizedMessage("Failed to clear scroll [{}]", scrollId), e); onCompletion.run(); } }); }
@Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { String scrollIds = request.param("scroll_id"); ClearScrollRequest clearRequest = new ClearScrollRequest(); clearRequest.setScrollIds(Arrays.asList(splitScrollIds(scrollIds))); request.withContentOrSourceParamParserOrNull((xContentParser -> { if (xContentParser != null) { // NOTE: if rest request with xcontent body has request parameters, values parsed from request body have the precedence try { clearRequest.fromXContent(xContentParser); } catch (IOException e) { throw new IllegalArgumentException("Failed to parse request body", e); } } })); return channel -> client.clearScroll(clearRequest, new RestStatusToXContentListener<>(channel)); }
@Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { String scrollIds = request.param("scroll_id"); ClearScrollRequest clearRequest = new ClearScrollRequest(); clearRequest.setScrollIds(Arrays.asList(splitScrollIds(scrollIds))); request.withContentOrSourceParamParserOrNull((xContentParser -> { if (xContentParser != null) { // NOTE: if rest request with xcontent body has request parameters, values parsed from request body have the precedence try { clearRequest.fromXContent(xContentParser); } catch (IOException e) { throw new IllegalArgumentException("Failed to parse request body", e); } } })); return channel -> client.clearScroll(clearRequest, new RestStatusToXContentListener<>(channel)); }
@Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { String scrollIds = request.param("scroll_id"); ClearScrollRequest clearRequest = new ClearScrollRequest(); clearRequest.setScrollIds(Arrays.asList(splitScrollIds(scrollIds))); request.withContentOrSourceParamParserOrNullLenient((xContentParser -> { if (xContentParser == null) { if (request.hasContent()) { // TODO: why do we accept this plain text value? maybe we can just use the scroll params? BytesReference body = request.content(); String bodyScrollIds = body.utf8ToString(); clearRequest.setScrollIds(Arrays.asList(splitScrollIds(bodyScrollIds))); } } else { // NOTE: if rest request with xcontent body has request parameters, values parsed from request body have the precedence try { clearRequest.fromXContent(xContentParser); } catch (IOException e) { throw new IllegalArgumentException("Failed to parse request body", e); } } })); return channel -> client.clearScroll(clearRequest, new RestStatusToXContentListener<>(channel)); }
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { String scrollIds = request.param("scroll_id"); ClearScrollRequest clearRequest = new ClearScrollRequest(); clearRequest.setScrollIds(Arrays.asList(splitScrollIds(scrollIds))); if (RestActions.hasBodyContent(request)) { XContentType type = RestActions.guessBodyContentType(request); if (type == null) { scrollIds = RestActions.getRestContent(request).toUtf8(); clearRequest.setScrollIds(Arrays.asList(splitScrollIds(scrollIds))); } else { // NOTE: if rest request with xcontent body has request parameters, these parameters does not override xcontent value clearRequest.setScrollIds(null); buildFromContent(RestActions.getRestContent(request), clearRequest); } } client.clearScroll(clearRequest, new RestStatusToXContentListener<ClearScrollResponse>(channel)); }