本文整理汇总了Java中org.elasticsearch.action.search.ClearScrollResponse类的典型用法代码示例。如果您正苦于以下问题:Java ClearScrollResponse类的具体用法?Java ClearScrollResponse怎么用?Java ClearScrollResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClearScrollResponse类属于org.elasticsearch.action.search包,在下文中一共展示了ClearScrollResponse类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearScroll
import org.elasticsearch.action.search.ClearScrollResponse; //导入依赖的package包/类
@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();
}
});
}
示例2: handleRequest
import org.elasticsearch.action.search.ClearScrollResponse; //导入依赖的package包/类
@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));
}
示例3: interrupt
import org.elasticsearch.action.search.ClearScrollResponse; //导入依赖的package包/类
public void interrupt() {
interrupted.set(true);
if (scrollId != null) {
client.prepareClearScroll().addScrollId(scrollId)
.execute(new ActionListener<ClearScrollResponse>() {
@Override
public void onResponse(ClearScrollResponse response) {
// nothing
}
@Override
public void onFailure(Throwable e) {
if (logger.isDebugEnabled()) {
logger.debug(
"Failed to stop reindexing for "
+ toIndex + ".", e);
}
}
});
}
}
示例4: testClearNonExistentScrollId
import org.elasticsearch.action.search.ClearScrollResponse; //导入依赖的package包/类
public void testClearNonExistentScrollId() throws Exception {
createIndex("idx");
ClearScrollResponse response = client().prepareClearScroll()
.addScrollId("DnF1ZXJ5VGhlbkZldGNoAwAAAAAAAAABFnRtLWMyRzBqUUQyNk1uM0xDTjJ4S0EAAAAAAAAAARYzNkhxbWFTYVFVNmgxTGQyYUZVYV9nAAAAAAAAAAEWdVcxNWZmRGZSVFN2V0xMUGF2NGx1Zw==")
.get();
// Whether we actually clear a scroll, we can't know, since that information isn't serialized in the
// free search context response, which is returned from each node we want to clear a particular scroll.
assertThat(response.isSucceeded(), is(true));
assertThat(response.getNumFreed(), equalTo(0));
assertThat(response.status(), equalTo(RestStatus.NOT_FOUND));
assertToXContentResponse(response, true, response.getNumFreed());
}
示例5: testThatNonExistingScrollIdReturnsCorrectException
import org.elasticsearch.action.search.ClearScrollResponse; //导入依赖的package包/类
public void testThatNonExistingScrollIdReturnsCorrectException() throws Exception {
client().prepareIndex("index", "type", "1").setSource("field", "value").execute().get();
refresh();
SearchResponse searchResponse = client().prepareSearch("index").setSize(1).setScroll("1m").get();
assertThat(searchResponse.getScrollId(), is(notNullValue()));
ClearScrollResponse clearScrollResponse = client().prepareClearScroll().addScrollId(searchResponse.getScrollId()).get();
assertThat(clearScrollResponse.isSucceeded(), is(true));
assertThrows(internalCluster().transportClient().prepareSearchScroll(searchResponse.getScrollId()), RestStatus.NOT_FOUND);
}
示例6: assertToXContentResponse
import org.elasticsearch.action.search.ClearScrollResponse; //导入依赖的package包/类
private void assertToXContentResponse(ClearScrollResponse response, boolean succeed, int numFreed) throws IOException {
XContentBuilder builder = XContentFactory.jsonBuilder();
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
Map<String, Object> map = XContentHelper.convertToMap(builder.bytes(), false, builder.contentType()).v2();
assertThat(map.get("succeeded"), is(succeed));
assertThat(map.get("num_freed"), equalTo(numFreed));
}
示例7: close
import org.elasticsearch.action.search.ClearScrollResponse; //导入依赖的package包/类
@Override
public void close() throws IOException {
if (response != null) {
ClearScrollResponse clearScrollResponse = client.prepareClearScroll()
.addScrollId(response.getScrollId())
.execute()
.actionGet();
if (!clearScrollResponse.isSucceeded()) {
LOGGER.debug("Failed to clear scroll: {}", clearScrollResponse.status());
}
}
}
示例8: clearScroll
import org.elasticsearch.action.search.ClearScrollResponse; //导入依赖的package包/类
/**
* Clears the given scroll Ids
*/
public void clearScroll(String... scrollIds) {
ClearScrollResponse clearResponse = client().prepareClearScroll()
.setScrollIds(Arrays.asList(scrollIds)).get();
assertThat(clearResponse.isSucceeded(), equalTo(true));
}
示例9: clearScroll
import org.elasticsearch.action.search.ClearScrollResponse; //导入依赖的package包/类
@Override
public void clearScroll(ClearScrollRequest request, ActionListener<ClearScrollResponse> listener) {
execute(ClearScrollAction.INSTANCE, request, listener);
}
示例10: clearScroll
import org.elasticsearch.action.search.ClearScrollResponse; //导入依赖的package包/类
@Override
public void clearScroll(ClearScrollRequest request,
ActionListener<ClearScrollResponse> listener) {
// TODO Auto-generated method stub
}
示例11: clearScroll
import org.elasticsearch.action.search.ClearScrollResponse; //导入依赖的package包/类
/**
* Clears the given scroll Ids
*/
public void clearScroll(final String... scrollIds) {
final ClearScrollResponse clearResponse = client().prepareClearScroll().setScrollIds(Arrays.asList(scrollIds)).get();
assertThat(clearResponse.isSucceeded(), equalTo(true));
}
示例12: clearScroll
import org.elasticsearch.action.search.ClearScrollResponse; //导入依赖的package包/类
/**
* Clears the search contexts associated with specified scroll ids.
*/
ActionFuture<ClearScrollResponse> clearScroll(ClearScrollRequest request);