SearchResponse sr = CLIENT.prepareSearch(EsSearch.getIndexName(masterIp, snifferDataAbnormal))
.setScroll(new TimeValue(Constants.SCROLL_TIME)).setQuery(query).setSize(SSML).execute().actionGet();
int sizeIterator = 100000;
ClearScrollRequestBuilder clearRequest = CLIENT.prepareClearScroll();
while (sizeIterator > 0 && sr.getHits().getHits().length > 0) {
logger.info("totalhits:" + sr.getHits().getTotalHits());
logger.info("transactionId:" + sr.getHits().getHits().length);
/*这里第一次查询就有了结果。*/
for (SearchHit hit : sr.getHits()) {
JSONObject hitJson = JSON.parseObject(hit.getSourceAsString());
hitJson.put("masterIp", context.masterIp());
try {
this.resolveHit(hitJson, context);
} catch (Exception e) {
logger.error("exception happened when resolve data to relationship", e);
return context;
}
}
try {
sr = CLIENT.prepareSearchScroll(sr.getScrollId()).setScroll(new TimeValue(60000)).execute().actionGet();
} finally {
sizeIterator = sizeIterator - SSML;
}
}
1 个回复
weizijun - elasticsearch fan
赞同来自: