# Elasticsearch Error: SearchPhaseExecutionException: All Shards Failed

**URL:** <https://discuss.elastic.co/t/elasticsearch-error-searchphaseexecutionexception-all-shards-failed/157816>\
**Category:** Elasticsearch\
**Created:** [November 22, 2018, 7:48am UTC](https://discuss.elastic.co/t/elasticsearch-error-searchphaseexecutionexception-all-shards-failed/157816 "2018-11-22T07:48:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dx123](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dx123](https://discuss.elastic.co/u/dx123)\
**Post date:** [November 22, 2018, 7:48am UTC](https://discuss.elastic.co/t/elasticsearch-error-searchphaseexecutionexception-all-shards-failed/157816/1 "2018-11-22T07:48:35Z")

</div>

Never encountered this error before until now. I'm indexing the results of an aggregation query performed on hundreds and thousands of documents when things failed and I got this error.

```
[2018-11-22T10:00:22,291][DEBUG][o.e.a.s.TransportSearchAction] [kFDS8ms] All shards failed for phase: [query]
[2018-11-22T00:00:22,292][WARN][r.suppressed] path: /.kibana/_search, params: {ignore_unavailable=true, index=.kibana, filter_path=aggregations.types.buckets}
org.elasticsearch.action.search.SearchPhaseExecutionException: all shards failed
	at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseFailure(AbstractSearchAsyncAction.java:293) ~[elasticsearch-6.4.2.jar:6.4.2]
	at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:133) ~[elasticsearch-6.4.2.jar:6.4.2]
	at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseDone(AbstractSearchAsyncAction.java:254) ~[elasticsearch-6.4.2.jar:6.4.2]
	at org.elasticsearch.action.search.InitialSearchPhase.onShardFailure(InitialSearchPhase.java:101) ~[elasticsearch-6.4.2.jar:6.4.2]
	at org.elasticsearch.action.search.InitialSearchPhase.lambda$performPhaseOnShard$1(InitialSearchPhase.java:210) ~[elasticsearch-6.4.2.jar:6.4.2]
	at org.elasticsearch.action.search.InitialSearchPhase$1.doRun(InitialSearchPhase.java:189) [elasticsearch-6.4.2.jar:6.4.2]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:723) [elasticsearch-6.4.2.jar:6.4.2]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-6.4.2.jar:6.4.2]
	at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:41) [elasticsearch-6.4.2.jar:6.4.2]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-6.4.2.jar:6.4.2]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_181]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_181]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181]
[2018-11-22T00:00:27,020][INFO][o.e.c.r.a.AllocationService] [kFDS8ms] Cluster health status changed from [RED] to [GREEN] (reason: [shards started [[.monitoring-es-6-2018.11.22][0]] ...]).

```

Here's my cluster settings. I researched about this online and most information that I could find were regarding unassigned shards, which doesn't seem to be the case for mine.

```
curl -XGET 'localhost:9200/_cluster/health?pretty' 
{
  "cluster_name" : "elasticsearch",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 75,
  "active_shards" : 75,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}
```

---

<div class="post-metadata">

**Author:** ![dx123](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dx123](https://discuss.elastic.co/u/dx123)\
**Post date:** [November 22, 2018, 8:40am UTC](https://discuss.elastic.co/t/elasticsearch-error-searchphaseexecutionexception-all-shards-failed/157816/2 "2018-11-22T08:40:41Z")

</div>

Apparently it was due to me performing the aggregation query on too many documents at one go. After I changed the time range from per month to half a month, it worked.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 20, 2018, 8:40am UTC](https://discuss.elastic.co/t/elasticsearch-error-searchphaseexecutionexception-all-shards-failed/157816/3 "2018-12-20T08:40:47Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
