elastic / go-elasticsearch

The official Go client for Elasticsearch
https://github.com/elastic/go-elasticsearch#go-elasticsearch
Apache License 2.0
65 stars 617 forks source link

Include RootCause in ElasticsearchError.Error() #906

Open arp242 opened 2 months ago

arp242 commented 2 months ago

Previously it would just report:

status: 400, failed: [x_content_parse_exception], reason: [1:77] [bool] failed to parse field [filter]

Which is just not very helpful; no idea what's wrong here. I've noticed this with quite a few errors over the last few weeks. The real error is "hidden" in the RootCause, so add that to the Error():

status: 400, failed: [x_content_parse_exception], reason: [1:77] [bool] failed to parse field [filter]: [term] query doesn't support multiple fields, found [collection_id] and [entities]

Which is a bit long, but at least it has the actual error in there.