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


Java SearchResponse.getFailedShards方法代码示例

本文整理汇总了Java中org.elasticsearch.action.search.SearchResponse.getFailedShards方法的典型用法代码示例。如果您正苦于以下问题:Java SearchResponse.getFailedShards方法的具体用法?Java SearchResponse.getFailedShards怎么用?Java SearchResponse.getFailedShards使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.action.search.SearchResponse的用法示例。


在下文中一共展示了SearchResponse.getFailedShards方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: check

import org.elasticsearch.action.search.SearchResponse; //导入方法依赖的package包/类
static void check(SearchResponse response) {
    if (response.status() != RestStatus.OK) {
        throw new StarGraphException("ES failure. RestStatus is " + response.status());
    }
    if (response.getFailedShards() > 0) {
        throw new StarGraphException("Shard Search Failure.");
    }
}
 
开发者ID:Lambda-3,项目名称:Stargraph,代码行数:9,代码来源:ESUtils.java

示例2: 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

示例3: testSimpleIndexTemplateTests

import org.elasticsearch.action.search.SearchResponse; //导入方法依赖的package包/类
public void testSimpleIndexTemplateTests() throws Exception {
    // clean all templates setup by the framework.
    client().admin().indices().prepareDeleteTemplate("*").get();

    // check get all templates on an empty index.
    GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates().get();
    assertThat(response.getIndexTemplates(), empty());


    client().admin().indices().preparePutTemplate("template_1")
            .setPatterns(Collections.singletonList("te*"))
            .setSettings(indexSettings())
            .setOrder(0)
            .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
                    .startObject("field1").field("type", "text").field("store", true).endObject()
                    .startObject("field2").field("type", "keyword").field("store", true).endObject()
                    .endObject().endObject().endObject())
            .get();

    client().admin().indices().preparePutTemplate("template_2")
            .setPatterns(Collections.singletonList("test*"))
            .setSettings(indexSettings())
            .setOrder(1)
            .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
                    .startObject("field2").field("type", "text").field("store", false).endObject()
                    .endObject().endObject().endObject())
            .get();

    // test create param
    assertThrows(client().admin().indices().preparePutTemplate("template_2")
            .setPatterns(Collections.singletonList("test*"))
            .setSettings(indexSettings())
            .setCreate(true)
            .setOrder(1)
            .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
                    .startObject("field2").field("type", "text").field("store", false).endObject()
                    .endObject().endObject().endObject())
            , IllegalArgumentException.class
    );

    response = client().admin().indices().prepareGetTemplates().get();
    assertThat(response.getIndexTemplates(), hasSize(2));


    // index something into test_index, will match on both templates
    client().prepareIndex("test_index", "type1", "1")
            .setSource("field1", "value1", "field2", "value 2")
            .setRefreshPolicy(IMMEDIATE).get();

    ensureGreen();
    SearchResponse searchResponse = client().prepareSearch("test_index")
            .setQuery(termQuery("field1", "value1"))
            .addStoredField("field1").addStoredField("field2")
            .execute().actionGet();

    assertHitCount(searchResponse, 1);
    assertThat(searchResponse.getHits().getAt(0).field("field1").getValue().toString(), equalTo("value1"));
    // field2 is not stored.
    assertThat(searchResponse.getHits().getAt(0).field("field2"), nullValue());

    client().prepareIndex("text_index", "type1", "1")
            .setSource("field1", "value1", "field2", "value 2")
            .setRefreshPolicy(IMMEDIATE).get();

    ensureGreen();
    // now only match on one template (template_1)
    searchResponse = client().prepareSearch("text_index")
            .setQuery(termQuery("field1", "value1"))
            .addStoredField("field1").addStoredField("field2")
            .execute().actionGet();
    if (searchResponse.getFailedShards() > 0) {
        logger.warn("failed search {}", Arrays.toString(searchResponse.getShardFailures()));
    }
    assertHitCount(searchResponse, 1);
    assertThat(searchResponse.getHits().getAt(0).field("field1").getValue().toString(), equalTo("value1"));
    assertThat(searchResponse.getHits().getAt(0).field("field2").getValue().toString(), equalTo("value 2"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:78,代码来源:SimpleIndexTemplateIT.java

示例4: 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.getFailedShards方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。