本文整理汇总了Java中org.elasticsearch.action.search.SearchResponse.getSuccessfulShards方法的典型用法代码示例。如果您正苦于以下问题:Java SearchResponse.getSuccessfulShards方法的具体用法?Java SearchResponse.getSuccessfulShards怎么用?Java SearchResponse.getSuccessfulShards使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.action.search.SearchResponse
的用法示例。
在下文中一共展示了SearchResponse.getSuccessfulShards方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatShardStatus
import org.elasticsearch.action.search.SearchResponse; //导入方法依赖的package包/类
public static String formatShardStatus(SearchResponse response) {
String msg = " Total shards: " + response.getTotalShards() + " Successful shards: " + response.getSuccessfulShards() + " & "
+ response.getFailedShards() + " shard failures:";
for (ShardSearchFailure failure : response.getShardFailures()) {
msg += "\n " + failure.toString();
}
return msg;
}
示例2: testScanScrollWithShardExceptions
import org.elasticsearch.action.search.SearchResponse; //导入方法依赖的package包/类
public void testScanScrollWithShardExceptions() throws Exception {
internalCluster().startNode();
internalCluster().startNode();
assertAcked(
prepareCreate("test")
// Enforces that only one shard can only be allocated to a single node
.setSettings(Settings.builder().put(indexSettings()).put(ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE_SETTING.getKey(), 1))
);
List<IndexRequestBuilder> writes = new ArrayList<>();
for (int i = 0; i < 100; i++) {
writes.add(
client().prepareIndex("test", "type1")
.setSource(jsonBuilder().startObject().field("field", i).endObject())
);
}
indexRandom(false, writes);
refresh();
SearchResponse searchResponse = client().prepareSearch()
.setQuery(matchAllQuery())
.setSize(10)
.setScroll(TimeValue.timeValueMinutes(1))
.get();
assertAllSuccessful(searchResponse);
long numHits = 0;
do {
numHits += searchResponse.getHits().getHits().length;
searchResponse = client()
.prepareSearchScroll(searchResponse.getScrollId()).setScroll(TimeValue.timeValueMinutes(1))
.get();
assertAllSuccessful(searchResponse);
} while (searchResponse.getHits().getHits().length > 0);
assertThat(numHits, equalTo(100L));
clearScroll("_all");
internalCluster().stopRandomNonMasterNode();
searchResponse = client().prepareSearch()
.setQuery(matchAllQuery())
.setSize(10)
.setScroll(TimeValue.timeValueMinutes(1))
.get();
assertThat(searchResponse.getSuccessfulShards(), lessThan(searchResponse.getTotalShards()));
numHits = 0;
int numberOfSuccessfulShards = searchResponse.getSuccessfulShards();
do {
numHits += searchResponse.getHits().getHits().length;
searchResponse = client()
.prepareSearchScroll(searchResponse.getScrollId()).setScroll(TimeValue.timeValueMinutes(1))
.get();
assertThat(searchResponse.getSuccessfulShards(), equalTo(numberOfSuccessfulShards));
} while (searchResponse.getHits().getHits().length > 0);
assertThat(numHits, greaterThan(0L));
clearScroll(searchResponse.getScrollId());
}
示例3: CountResponse
import org.elasticsearch.action.search.SearchResponse; //导入方法依赖的package包/类
public CountResponse(SearchResponse searchResponse) {
super(searchResponse.getTotalShards(), searchResponse.getSuccessfulShards(), searchResponse.getFailedShards(), Arrays.asList(searchResponse.getShardFailures()));
this.count = searchResponse.getHits().totalHits();
this.terminatedEarly = searchResponse.isTerminatedEarly() != null && searchResponse.isTerminatedEarly();
}