Elasticsearch Error: SearchPhaseExecutionException: All Shards Failed

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.