Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java elasticsearch失败并出现错误“;无法执行阶段[query_fetch],所有碎片均失败;_Java_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch - Fatal编程技术网 elasticsearch,Java,elasticsearch" /> elasticsearch,Java,elasticsearch" />

Java elasticsearch失败并出现错误“;无法执行阶段[query_fetch],所有碎片均失败;

Java elasticsearch失败并出现错误“;无法执行阶段[query_fetch],所有碎片均失败;,java,elasticsearch,Java,elasticsearch,当我尝试为数据编制索引,然后执行查询时,一切都很好,但如果我启动我的应用程序,并在未编制索引的情况下执行查询,则会出现该错误 Exception in thread "main" org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [query_fetch], all shards failed at org.elasticsearch.action.search.type.

当我尝试为数据编制索引,然后执行查询时,一切都很好,但如果我启动我的应用程序,并在未编制索引的情况下执行查询,则会出现该错误

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)
这是我的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
//设置
ImmutableSettings.Builder设置=ImmutableSettings.settingsBuilder();
settings.put(“client.transport.sniff”,false);
settings.put(“path.home”,“/path/to/elastic/home”);
设置.put(“索引.副本的数量”,0);
设置.put(“索引.碎片数”,1);
设置。放置(“操作。写入一致性”,“一”);
settings.build();
//创建节点和客户端
NodeBuilder nb=new NodeBuilder().settings(settings).local(true).data(true);
Node=nb.Node();
Client=node.Client();
/*

对于(inti=0;i在添加睡眠后,比如10秒,你能尝试同样的方法吗

Client client = node.client();
我觉得Elasticsearch在你点击搜索请求之前还没有恢复碎片。
甚至管理员呼叫“等待黄色”应该适合你

你不能搜索不存在的索引/类型,可以吗?通过注释掉twitter2/tweet2的索引,你就没有什么可搜索的了。但是我在path/path/to/elastic/home文件夹中看到了,其中包含我以前创建的索引,因此我认为这是可能的。你需要设置一个path.data,这样数据就可以被删除在两次运行之间是否存在相同的位置?现在我的应用程序可以从elastic中找到旧数据,前提是在它之前我对某些内容进行了索引,因此错误不在路径中(我的意见:)有人有什么想法吗?