Improve error condition communication from backend

Previously if the backend was unable to connect to Elasticsearch it would simply throw an "Internal Server Error". This change sets the HTTP status to 502 (bad gateway) or 504 (gateway timeout) depending on Elasticsearch's availability. It also communicates that in the fatal message.