java elasticsearch 失败并显示错误“无法执行阶段 [query_fetch],所有分片失败”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25644182/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
elasticsearch fail with error "Failed to execute phase [query_fetch], all shards failed"
提问by user3569530
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.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.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
What is wrong in me settings?
我的设置有什么问题?
采纳答案by Vineeth Mohan
Can you try the same after adding a sleep for say 10 seconds after
您可以在添加睡眠后尝试相同的 10 秒后吗
Client client = node.client();
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
我觉得 Elasticsearch 在您点击搜索请求之前还没有恢复分片。即使是“等待黄色”的管理员电话也应该适合您