Correct, this is what will be logged by default, if the exception is not handled. By catching the ElasticsearchException you can customize the depth of error you can log, for example:
public static void main(String[] args) throws IOException {
try (
ElasticsearchClient client = ElasticsearchClient.of(e -> e
.host("host")
.apiKey("apikey"))) {
client.search(s -> s
.index("test")
.query(q -> q
.queryString(qs -> qs
.query("\"test")))
);
} catch (ElasticsearchException e) {
System.out.println(e.error());
}
}
will print:
ErrorCause: {"phase":"query","failed_shards":[{"shard":0,"index":"test","node":"uLsAhJL1SG6fVTHEDpVP7w","reason":{"type":"query_shard_exception","reason":"Failed to parse query [\"test]","index_uuid":"7FHHQQkBREG2GsOemvrlyw","index":"test","caused_by":{"type":"parse_exception","reason":"Cannot parse '\"test': Lexical error at line 1, column 6. Encountered: <EOF> after prefix \"\\\"test\" (in lexical state 2)","caused_by":{"type":"token_mgr_error","reason":"Lexical error at line 1, column 6. Encountered: <EOF> after prefix \"\\\"test\" (in lexical state 2)"}}}}],"grouped":true,"type":"search_phase_execution_exception","reason":"all shards failed","root_cause":[{"index_uuid":"7FHHQQkBREG2GsOemvrlyw","index":"test","type":"query_shard_exception","reason":"Failed to parse query [\"test]"}]}
which is the same thing you’d see in Kibana ![]()