當前位置: 首頁>>代碼示例>>Java>>正文


Java SearchResponse.getShardFailures方法代碼示例

本文整理匯總了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());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:25,代碼來源:ClientScrollableHitSource.java

示例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));
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:18,代碼來源:IndexLookupIT.java

示例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;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:9,代碼來源:ElasticsearchAssertions.java

示例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()));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,代碼來源:StatsIT.java

示例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);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:9,代碼來源:RecoveryWhileUnderLoadIT.java


注:本文中的org.elasticsearch.action.search.SearchResponse.getShardFailures方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。