Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More specific error messages in R package #159

Open
jameslamb opened this issue Aug 22, 2019 · 0 comments
Open

More specific error messages in R package #159

jameslamb opened this issue Aug 22, 2019 · 0 comments

Comments

@jameslamb
Copy link
Collaborator

Discovered while working on #155. When the R client receives an error from ES (a non-2xx response code), currently the code fails with an error just like "error: 404" or something like that.

I think it would be valuable to instead have uptasticsearch trap non-2xx response codes and then log out the full content of the error message from Elasticsearch.

For example, before fixing #155 I found that running this code

uptasticsearch::es_search(
    es_host = "http://127.0.0.1:9200"
    , es_index = "shakespeare"
    , max_hits = 100
    , query = "{\"aggs\": {\"name_i_picked\": {\"terms\": {\"field\": \"speaker\", \"size\": 12}}}}"
)

returns

INFO [2019-08-21 22:35:37] es_search detected that this is an aggs request and will only return aggregation results.
Request failed [400]. Retrying in 1 seconds...
Request failed [400]. Retrying in 1 seconds...
Error in .search_request(es_host = es_host, es_index = es_index, trailing_args = "size=0",  : 
  Bad Request (HTTP 400).

Where the same curl request

curl -X POST \
    -i \
    "http://127.0.0.1:9200/shakespeare/_search" \
    -H "Content-Type: application/json" \
    -d '{"aggs": {"name_i_picked": {"terms": {"field": "speaker", "size": 12}}}}'

returns the much more informative error

HTTP/1.1 400 Bad Request
content-type: application/json; charset=UTF-8
content-length: 1442

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [speaker] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"shakespeare","node":"FXsoOzioR_CZqUSQMsWmAg","reason":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [speaker] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}}],"caused_by":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [speaker] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.","caused_by":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [speaker] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}}},"status":400}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant