class Elasticsearch::Model::Response::Result
Encapsulates the “hit” returned from the Elasticsearch
client
Wraps the raw Hash with in a `Hashie::Mash` instance, providing access to the Hash properties by calling Ruby methods.
Public Class Methods
new(attributes={})
click to toggle source
@param attributes [Hash] A Hash with document properties
# File lib/elasticsearch/model/response/result.rb, line 33 def initialize(attributes={}) @result = HashWrapper.new(attributes) end
Public Instance Methods
as_json(options={})
click to toggle source
# File lib/elasticsearch/model/response/result.rb, line 72 def as_json(options={}) @result.as_json(options) end
id()
click to toggle source
Return document `_id` as `id`
# File lib/elasticsearch/model/response/result.rb, line 39 def id @result['_id'] end
method_missing(name, *arguments)
click to toggle source
Delegate methods to `@result` or `@result._source`
Calls superclass method
# File lib/elasticsearch/model/response/result.rb, line 51 def method_missing(name, *arguments) case when name.to_s.end_with?('?') @result.__send__(name, *arguments) || ( @result._source && @result._source.__send__(name, *arguments) ) when @result.respond_to?(name) @result.__send__ name, *arguments when @result._source && @result._source.respond_to?(name) @result._source.__send__ name, *arguments else super end end
respond_to_missing?(method_name, include_private = false)
click to toggle source
Respond to methods from `@result` or `@result._source`
Calls superclass method
# File lib/elasticsearch/model/response/result.rb, line 66 def respond_to_missing?(method_name, include_private = false) @result.respond_to?(method_name.to_sym) || \ @result._source && @result._source.respond_to?(method_name.to_sym) || \ super end
type()
click to toggle source
Return document `_type` as `_type`
# File lib/elasticsearch/model/response/result.rb, line 45 def type @result['_type'] end