本文整理汇总了Java中org.elasticsearch.action.search.SearchResponse.getShardFailures方法的典型用法代码示例。如果您正苦于以下问题:Java SearchResponse.getShardFailures方法的具体用法?Java SearchResponse.getShardFailures怎么用?Java SearchResponse.getShardFailures使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.action.search.SearchResponse
的用法示例。
在下文中一共展示了SearchResponse.getShardFailures方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: wrap
import org.elasticsearch.action.search.SearchResponse; //导入方法依赖的package包/类
private Response wrap(SearchResponse response) {
List<SearchFailure> failures;
if (response.getShardFailures() == null) {
failures = emptyList();
} else {
failures = new ArrayList<>(response.getShardFailures().length);
for (ShardSearchFailure failure: response.getShardFailures()) {
String nodeId = failure.shard() == null ? null : failure.shard().getNodeId();
failures.add(new SearchFailure(failure.getCause(), failure.index(), failure.shardId(), nodeId));
}
}
List<Hit> hits;
if (response.getHits().getHits() == null || response.getHits().getHits().length == 0) {
hits = emptyList();
} else {
hits = new ArrayList<>(response.getHits().getHits().length);
for (SearchHit hit: response.getHits().getHits()) {
hits.add(new ClientHit(hit));
}
hits = unmodifiableList(hits);
}
return new Response(response.isTimedOut(), failures, response.getHits().getTotalHits(),
hits, response.getScrollId());
}
示例2: checkExceptions
import org.elasticsearch.action.search.SearchResponse; //导入方法依赖的package包/类
private void checkExceptions(Script script) {
try {
SearchResponse sr = client().prepareSearch("test").setQuery(QueryBuilders.matchAllQuery()).addScriptField("tvtest", script)
.execute().actionGet();
assertThat(sr.getHits().getHits().length, equalTo(0));
ShardSearchFailure[] shardFails = sr.getShardFailures();
for (ShardSearchFailure fail : shardFails) {
assertThat(fail.reason().indexOf("Cannot iterate twice! If you want to iterate more that once, add _CACHE explicitly."),
Matchers.greaterThan(-1));
}
} catch (SearchPhaseExecutionException ex) {
assertThat(
"got " + ex.toString(),
ex.toString().indexOf("Cannot iterate twice! If you want to iterate more that once, add _CACHE explicitly."),
Matchers.greaterThan(-1));
}
}
示例3: 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;
}
示例4: assertShardExecutionState
import org.elasticsearch.action.search.SearchResponse; //导入方法依赖的package包/类
private void assertShardExecutionState(SearchResponse response, int expectedFailures) throws Exception {
ShardSearchFailure[] failures = response.getShardFailures();
if (failures.length != expectedFailures) {
for (ShardSearchFailure failure : failures) {
logger.error((Supplier<?>) () -> new ParameterizedMessage("Shard Failure: {}", failure), failure.getCause());
}
fail("Unexpected shard failures!");
}
assertThat("Not all shards are initialized", response.getSuccessfulShards(), equalTo(response.getTotalShards()));
}
示例5: logSearchResponse
import org.elasticsearch.action.search.SearchResponse; //导入方法依赖的package包/类
private void logSearchResponse(int numberOfShards, long numberOfDocs, int iteration, SearchResponse searchResponse) {
logger.info("iteration [{}] - successful shards: {} (expected {})", iteration, searchResponse.getSuccessfulShards(), numberOfShards);
logger.info("iteration [{}] - failed shards: {} (expected 0)", iteration, searchResponse.getFailedShards());
if (searchResponse.getShardFailures() != null && searchResponse.getShardFailures().length > 0) {
logger.info("iteration [{}] - shard failures: {}", iteration, Arrays.toString(searchResponse.getShardFailures()));
}
logger.info("iteration [{}] - returned documents: {} (expected {})", iteration, searchResponse.getHits().getTotalHits(), numberOfDocs);
}