BoolQueryBuilder bool=QueryBuilders.boolQuery();
SearchResponse searchResponse = esClient.prepareSearch("index")
.setTypes("type")
.setSize(10000)
//这个游标维持多长时间
.setScroll(TimeValue.timeValueMinutes(8))
.execute().actionGet();
System.out.println(searchResponse.getHits().getTotalHits());
while(true){
for (SearchHit hit : searchResponse.getHits()) {
System.out.println(hit.getSourceAsString()));
}
searchResponse = esClient.prepareSearchScroll(searchResponse.getScrollId())
.setScroll(TimeValue.timeValueMinutes(8))
.execute().actionGet();
if (searchResponse.getHits().getHits().length == 0) {
break;
}
}
SearchResponse searchResponse = esClient.prepareSearch("index")
.setTypes("type")
.setSize(10000)
//这个游标维持多长时间
.setScroll(TimeValue.timeValueMinutes(8))
.execute().actionGet();
System.out.println(searchResponse.getHits().getTotalHits());
while(true){
for (SearchHit hit : searchResponse.getHits()) {
System.out.println(hit.getSourceAsString()));
}
searchResponse = esClient.prepareSearchScroll(searchResponse.getScrollId())
.setScroll(TimeValue.timeValueMinutes(8))
.execute().actionGet();
if (searchResponse.getHits().getHits().length == 0) {
break;
}
}
[尊重社区原创,转载请保留或注明出处]
本文地址:http://elasticsearch.cn/article/82
本文地址:http://elasticsearch.cn/article/82