當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。