'Search phase execution exception with reason all shards failed
I am working on elastic search in spring boot REST API. I am getting the following exception while executing search query with ElasticSearch Java Client.
org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]
Following is my code:
String query = path + "\"" + path + "\"";
SearchRequest request = new SearchRequest();
request.indicesOptions(IndicesOptions.fromOptions(true, true, true, true));
String [] indices = new String[]{"index1", index2"};
request.indices(indices);
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
QueryBuilder queryBuilder = QueryBuilders.queryStringQuery(query);
sourceBuilder.size(1);
sourceBuilder.fetchSource("field_1", null);
sourceBuilder.query(queryBuilder);
request.source(sourceBuilder);
SearchResponse searchResponse = elasticsearchClient.getRestClient().search(request, RequestOptions.DEFAULT); ---> This line is throwing error.
And this issue seems intermittent during initialisation of ES and when indices are being created. Once after creation of indices, this issue is not occurring.
Can anyone help me on how we can eat this issue smoothly. Thank you in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
