You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Elasticsearch 1.0 api is removing the ok attributes that have historically been used to detect successful responses. In several of these apis it is unclear how to detect a successful response from the response body.
I've resisted this so far, but I wonder if now might be the time to start returning a Response object instead of the raw response hash. My initial vision for this is as simple as possible:
class Response < Hash
attr_accessor :status, :headers
end
This would allow api consumers to do things like:
response = docs.index(document)
if response.status != 201
# fail
end
I'd avoid adding abstractions like success? unless there was a clear benefit from having them in the low level client. IMO those kinds of things should be at a higher level (even though we don't have a higher level yet). The Response object is necessary in the client because the information would otherwise be unretrievable.
/cc @github/search
The text was updated successfully, but these errors were encountered:
While we may discover a way to detect success or failure from the response, I think the Elasticsearch devs feel that the response status is the canonical way to detect success or failure. See elastic/elasticsearch#4310
The Elasticsearch 1.0 api is removing the
ok
attributes that have historically been used to detect successful responses. In several of these apis it is unclear how to detect a successful response from the response body.I've resisted this so far, but I wonder if now might be the time to start returning a
Response
object instead of the raw response hash. My initial vision for this is as simple as possible:This would allow api consumers to do things like:
I'd avoid adding abstractions like
success?
unless there was a clear benefit from having them in the low level client. IMO those kinds of things should be at a higher level (even though we don't have a higher level yet). The Response object is necessary in the client because the information would otherwise be unretrievable./cc @github/search
The text was updated successfully, but these errors were encountered: