当前位置: 首页>>代码示例>>Java>>正文


Java SearchResponse.getSuccessfulShards方法代码示例

本文整理汇总了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;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:ElasticsearchAssertions.java

示例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());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:58,代码来源:SearchScrollWithFailingNodesIT.java

示例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();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:6,代码来源:CountResponse.java


注:本文中的org.elasticsearch.action.search.SearchResponse.getSuccessfulShards方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。