Class: ElasticSearch::Response
- Inherits:
-
Object
- Object
- ElasticSearch::Response
- Defined in:
- lib/elastic_search/response.rb
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(options) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(options) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/elastic_search/response.rb', line 5 def initialize() @body = [:body].eql?("") ? "{}" : [:body] @status = [:status].to_i case @status when 200..206 when 404 if self.body['error'] =~ /^IndexMissingException/ || self.body.eql?(nil) raise ElasticSearch::IndexMissingException, "#{self.body['status']}: #{self.body['error']}" elsif self.body['exists'].eql?(false) raise ElasticSearch::ItemMissingException, "_id: #{self.body['id']} NOT FOUND" else raise ElasticSearch::NotFoundError end else raise ElasticSearch::ResponseError, "#{self.body['status']}: #{self.body['error']}" end end |
Instance Attribute Details
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/elastic_search/response.rb', line 3 def status @status end |
Instance Method Details
#body ⇒ Object
24 25 26 |
# File 'lib/elastic_search/response.rb', line 24 def body @decoded_body ||= (@body ? ActiveSupport::JSON.decode(@body) : {}) end |