当前位置: 首页>>代码示例>>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;未经允许,请勿转载。