弹性搜索失败,错误“无法执行阶段[query_fetch],所有分片失败” [英] elasticsearch fail with error "Failed to execute phase [query_fetch], all shards failed"

查看:1727
本文介绍了弹性搜索失败,错误“无法执行阶段[query_fetch],所有分片失败”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试索引数据然后执行查询时,一切都是好的,但是如果我启动我的应用程序,并且会在没有索引的情况下进行查询,然后再收到该错误。

When i try to index data and then do query, all is good, but if i start my app and will do query without indexing before it i get that error

Exception in thread "main" org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [query_fetch], all shards failed at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:272)
    at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$3.onFailure(TransportSearchTypeAction.java:224)
    at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteFetch(SearchServiceTransportAction.java:307)
    at org.elasticsearch.action.search.type.TransportSearchQueryAndFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryAndFetchAction.java:71)
    at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:216)
    at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:203)
    at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:186)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

这是我的弹性搜索的代码和设置

Here is my code and settings of elasticsearch

    //  settings
    ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();
    settings.put("client.transport.sniff", false);
    settings.put("path.home", "/path/to/elastic/home");
    settings.put("index.number_of_replicas", 0);
    settings.put("index.number_of_shards", 1);
    settings.put("action.write_consistency", "one");

    settings.build();
    // creating of node and client
    NodeBuilder nb = new NodeBuilder().settings(settings).local(true).data(true);
    Node node = nb.node();
    Client client = node.client();


    /*
         for (int i = 0; i <= 15; i++) {
         IndexResponse response = client.prepareIndex("twitter2", "tweet2", String.valueOf(i))
                .setSource(json1)
                .execute()
                .actionGet();
         }
   */

       searchRequestBuilder = client.prepareSearch("twitter2")
            .setTypes("tweet2")
            .setQuery(QueryBuilders.matchQuery("user", "user0"))
            .setQuery(QueryBuilders.matchQuery("message","message1"))
            .setExplain(true)
            .setSearchType(SearchType.DFS_QUERY_AND_FETCH).setSize(200);

        SearchResponse searchRespons = searchRequestBuilder.execute().actionGet(); // here is error

我的设置有什么问题?

推荐答案

Client client = node.client();

我感到Elasticsearch没有恢复分片,然后才能达到搜索请求。
即使管理员呼叫等待黄色也适用于您

I feel Elasticsearch haven't recovered the shards before you have hit the search request. Even the admin call to "wait for yellow" should work for you

这篇关于弹性搜索失败,错误“无法执行阶段[query_fetch],所有分片失败”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆