first thing first, all shards failed exception is not as dramatic as it sounds, it means shards were failed while serving a request(query or index), and there could be multiple reasons for it like
- Shards are actually in non-recoverable state, if your cluster and index state are in Yellow and RED, then it is one of the reasons.
- Due to some shard recovery happening in background, shards didn't respond.
- Due to bad syntax of your query, ES responds in all shards failed.
In order to fix the issue, you need to filter it in one of the above category and based on that appropriate fix is required.
The one mentioned in the question, is clearly in the first bucket as cluster health is RED, means one or more primary shards are missing, and my this SO answer will help you fix RED cluster issue, which will fix the all shards exception in this case.