Validate queries before executing them

Rather than show the raw elasticsearch errors, use the validateQuery
method to check them, then return a more friendly error message if the
query isn't valid as well as setting the status code to 400 to indicate
a client error, rather than a 500.